<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ForceEffectParameters/setForce(_:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation21ForceEffectParametersV03setC0_5indexys5SIMD3VySfG_SitF"
  },
  "title" : "setForce(_:index:)"
}
-->

# setForce(_:index:)

Sets the force for each rigid body.

```
func setForce(_ force: SIMD3<Float>, index: Int)
```

## Parameters

`force`

The force value.

`index`

The index to the rigid body. The index should be in the range [0, [`physicsBodyCount`](/documentation/RealityKit/ForceEffectParameters/physicsBodyCount)].

## Discussion

Inside the force effect update function, you are responsible to compute and output the force
by calling this function for each rigid body. If you omit this function for a rigid body, that rigid body
gets zero force from the effect.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)