- Home /
Disabling the Z axis?
Hello,
i have Created a Sphere with a texture on it.
The texture shows multiple pictures and the user is able to rotate the sphere left and right, and up and down...is there a way i can lock the Z axis' rotation to zero, so my rotation doesn't become threedimensional?
here's my script
var kugel : GameObject;
function Start()
{
}
function Update () {
if(Input.GetKey("a"))
{
kugel.transform.Rotate(0,35*Time.deltaTime,0);
}
if(Input.GetKey("d"))
{
kugel.transform.Rotate(0,-35*Time.deltaTime,0);
}
if(Input.GetKey("w"))
{
kugel.transform.Rotate(35*Time.deltaTime,0,0);
}
if(Input.GetKey("s"))
{
kugel.transform.Rotate(-35*Time.deltaTime,0,0);
}
}
Answer by CHPedersen · Jun 14, 2011 at 09:33 AM
Instead of using transform.Rotate, consider transform.RotateAroundLocal. It rotates the object around a vector, effectively locking rotation to one axis. Then simply specify Vector3.up, for instance, if you only want to rotate the object around its own y axis.
Your answer
Follow this Question
Related Questions
[SOLVED]Possible Alternation of Transform.Rotate 1 Answer
2D sprite rotation with velocity and interpolation 1 Answer
2D game movement/jump issue 2 Answers
Have a 'Torch' script toggle on and off 1 Answer
Question Concerning transform.Rotate 1 Answer