void ApplyImpulse( Vector3 vel, bool withMass )

robot_2Generated
code_blocksInput

Description

The ApplyImpulse method applies an impulse to all physics bodies within the PhysicsGroup. This impulse is applied in the direction and magnitude specified by the vel parameter. The withMass parameter determines whether the impulse should be scaled by the mass of the bodies.

Usage

Use this method when you want to apply a sudden force to all bodies in a PhysicsGroup, such as simulating an explosion or a sudden push. The vel parameter should be a Vector3 representing the direction and strength of the impulse. Set withMass to true if you want the impulse to be affected by the mass of the bodies, or false if you want a uniform impulse regardless of mass.

Example

// Example of applying an impulse to a PhysicsGroup
PhysicsGroup group = new PhysicsGroup();
Vector3 impulseDirection = new Vector3(10, 0, 0); // Impulse in the x-direction
bool scaleWithMass = true; // Scale impulse by mass

// Apply the impulse to the group
group.ApplyImpulse(impulseDirection, scaleWithMass);