void AddVelocity( Vector3 vel )

book_4_sparkGenerated
code_blocksInput

Description

The AddVelocity method is a member of the PhysicsGroup class in the Sandbox namespace. This method allows you to add a specified velocity to all physics bodies within the group. It is useful for applying a uniform motion to a collection of physics bodies, such as simulating a push or a force applied to a group of objects.

Usage

To use the AddVelocity method, you need to have an instance of the PhysicsGroup class. You can then call this method with a Vector3 parameter representing the velocity you wish to add to the group.

Parameters:

  • vel (Vector3): The velocity vector to be added to each physics body in the group.

Example

// Create a new PhysicsGroup instance
PhysicsGroup physicsGroup = new PhysicsGroup();

// Define a velocity vector
Vector3 velocity = new Vector3(10, 0, 0);

// Add the velocity to the physics group
physicsGroup.AddVelocity(velocity);