how to change the force Direction

I Use this to move the object:
rigidbody.AddForce(transform.forward * moveSpeed * Time.deltaTime, ForceMode.Impulse);

how can i to change the force Direction ?

I want to use the addforce to move the object like “3rd Person Controller”

when i use the addforce to move the object and transform.rotate to change the object Direction but the object move Direction not the object forward

The answer above is right, but also, you can rotate the object, and then transform.forward will change (relative to the world). In an asteroids style 2d game for example, you would always use transform.forward, and then simply manipulate the rotation of the object.

Instead of transform.forward, write out Vector3(0,0,0) and in the (0,0,0) put whatever force you like. So to move up would be (0,5,0).

var fwd: float = Input.GetAxis(“Vertical”);
rigidbody.AddForce(transform.forward * (driveForce * fwd));
var steer: float = -Input.GetAxis(“Horizontal”);
rigidbody.AddForceAtPosition(transform.right * (steerForce * steer), transform.TransformPoint(Vector3.forward * steerPosZ));

This rotates your object by the left and right inputs and then moves it forward by the up an down.


Ooops again