- Home /
Add Force to the right of the rigidbody, not right of the screen
Using addforce to a rigidbody with vector3.right causes it to move right, even if it is rotated. My question is, how can you get the rigidbody to move from its angle. For example:
and not:
movetoangle.png
(2.6 kB)
move.png
(2.5 kB)
Comment
Best Answer
Answer by OtsegoDoom · Apr 25, 2014 at 02:58 PM
Use AddRelativeForce rather than AddForce. AddForce uses the global coordinate system, AddRelativeForce is local to the target object.
var force : Vector3;
gameObject.rigidbody.AddRelativeForce(force);