---
title: "setForce(_:index:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/forceeffectparameters/setforce(_:index:)"
---

# setForce(_:index:)

Sets the force for each rigid body.

## Declaration

```swift
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, doc://com.apple.RealityKit/documentation/RealityKit/ForceEffectParameters/physicsBodyCount].

## Discussion

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.
