The Bodies
property of the PhysicsWorld
class provides access to all the physics bodies present within the physics world. This property returns an IEnumerable<PhysicsBody>
, allowing you to iterate over each PhysicsBody
in the world.
The Bodies
property of the PhysicsWorld
class provides access to all the physics bodies present within the physics world. This property returns an IEnumerable<PhysicsBody>
, allowing you to iterate over each PhysicsBody
in the world.
Use the Bodies
property when you need to access or iterate over all the physics bodies in a PhysicsWorld
. This can be useful for operations such as applying a force to all bodies, checking their states, or performing custom updates.
// Example of iterating over all physics bodies in a PhysicsWorld PhysicsWorld physicsWorld = new PhysicsWorld(); foreach (PhysicsBody body in physicsWorld.Bodies) { // Perform operations on each body body.ApplyForce(new Vector3(0, 0, -9.81f)); // Example: Apply gravity }