- Home /
Problem with rotation
I'm using this script to rotate my plane, but when it rotates it also moves its transform on the Z axis, how can i fix this?
if (Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(Vector3.up * rotspeed * Time.deltaTime);
if (Input.GetKey(KeyCode.RightArrow))
transform.Rotate(-Vector3.up * rotspeed * Time.deltaTime);
There is nothing here that would change the position. Is the plane a child and is the script on the parent?
Do you have a rigid body on the plane? Just a wild guess...
How is your object axis when playing? Is your object modelized along the world axis?
Rigidbody will not effect rotations unless told to. Using transform will still work with or without a rigidbody.
Answer by GC1983 · Aug 04, 2013 at 07:40 AM
There could be a series of issues of why yours is not working...possibly due to alterations that you made that you might have not realized. Could be settings....either way. rotating on any axis is simple as one line of code. If its not working, its probably something youre overanalyzing. Check this link. It should help.
http://answers.unity3d.com/questions/9019/how-to-set-a-single-axis-rotation-of-a-gameobject.html
Your answer
