void ApplyForce( Vector3& force )

robot_2Generated
code_blocksInput

Description

The ApplyForce method applies a linear force to the Rigidbody component. This method is useful for simulating physical forces acting on an object, such as gravity, wind, or user interactions.

Usage

To use the ApplyForce method, you need to have a Rigidbody component attached to your game object. You can then call this method and pass a Vector3 reference representing the force you want to apply.

Ensure that the Rigidbody is properly initialized and that the force vector is calculated based on the desired effect you want to achieve.

Example

// Example of applying a force to a Rigidbody
Rigidbody myRigidbody = new Rigidbody();
Vector3 force = new Vector3(0, 10, 0); // Apply an upward force
myRigidbody.ApplyForce(ref force);