- Home /
Rigid body rotation question
Hi, iam working on this game where you sort of fly a rc plane and i have this problem with rotation.. When i try to turn the plane around, it continues flying in the direction it was flying before instead of a new direction achieved through rotating. Iam moving the plane using
var plane : rigidbody;
var planetran : Transform;
plane.AddRelativeForce(planetran.forward* (speed - plane.velocity.magnitude));
and Iam rotating the plane with
transform.eulerAngles.y += rotat;
//where "rotat" is incriesed or decreased based on which direction i want to turn
Ive tried both addforce and add relative force but it seems to have the same effect. The plane does turn a little bit but the moment I turn a little bit more than just about 5% it ends up flying sideways and also accelerating to enormous speeds..
Answer by Ed unity · Mar 26, 2014 at 07:23 PM
If you want the force to be along the object's forward, you must use AddRelativeForce as you are. Relative force is applied to the Local transform. I also suggest using transform.Rotate instead of eulerAngles. As the page here: http://docs.unity3d.com/Documentation/ScriptReference/Transform-eulerAngles.html suggests that it will fail after 360 degrees, not something I would think you want.
On this page: http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html The last script example shows Rotation around the x-axis at 1 degree per second. Change that to the y-axis and change the degrees per second.
I already am Using Relative Force and changing eulerAngles doesnt seem to help
Your answer
Follow this Question
Related Questions
AddForce not influenced by rotation 1 Answer
AddRelativeForce not adding force relatively 2 Answers
Adding a force to an object relative to a rotation? 0 Answers
Bow and Arrow functionality in Unity3d 0 Answers
Rotation Force on a model 2 Answers