PhysicsBody GetBody( int groupIndex )
PhysicsBody GetBody( string groupName )

book_4_sparkGenerated
code_blocksInput

Description

The GetBody method retrieves a PhysicsBody from the PhysicsGroup based on the specified groupIndex. This method is useful for accessing individual physics bodies within a group, such as when you need to apply specific transformations or retrieve properties from a particular body.

Usage

To use the GetBody method, you need to have an instance of PhysicsGroup. Call the method with the desired groupIndex to obtain the corresponding PhysicsBody. Ensure that the groupIndex is within the valid range of the group's body count to avoid exceptions.

Example

// Example of using GetBody method
PhysicsGroup physicsGroup = new PhysicsGroup();
int index = 0; // Index of the body you want to retrieve
PhysicsBody body = physicsGroup.GetBody(index);

// Now you can manipulate the PhysicsBody
body.Velocity = new Vector3(0, 0, 10); // Set velocity of the body