The ApplyForce
method applies a linear force to the Rigidbody
component. This method is used to influence the motion of the object by applying a force vector, which can affect the velocity and direction of the object.
The ApplyForce
method applies a linear force to the Rigidbody
component. This method is used to influence the motion of the object by applying a force vector, which can affect the velocity and direction of the object.
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. The force vector should be in world coordinates.
// Example of applying a force to a Rigidbody Rigidbody myRigidbody = GetComponent<Rigidbody>(); Vector3 force = new Vector3(0, 10, 0); // Apply an upward force myRigidbody.ApplyForce(ref force);