- Home /
How do I check the direction a rigidbody is facing from North and then addforce so it moves in that direction?
I am using a simple script to change direction of a rigidbody. How do I check to see what angle this rigidbody is facing in relation to North, and then addforce to the rigidbody to make it move in that direction.
What's 'North'? I didn't know there was any such thing in Unity!
Answer by Demigiant · Nov 28, 2011 at 11:02 PM
Uhm, if for North you mean "forward", you can check the rigidbody's degrees angle via:
transform.rotation.eulerAngles.y
To just make it move forward in the direction its facing, you can simply use this:
rigidbody.AddForce( transform.TransformDirection( Vector3.forward * speed ) );
[1]: http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613055905im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rigidbodies won't collide if mass difference is too high 0 Answers
Object jumping while moving(with addForce) 0 Answers
Bonding rigidbodies, then making them seperate when they get exploded 1 Answer
Detecting Input on ~100 Objects 2 Answers
Guidelines for using rigidbody, collider, CharacterControllerScript, etc? 3 Answers