- Home /
Locking Rotation object on Z axis
Simple question how do I lock the rotation of an object. Ive set it up so when you press the up and down arrow the turret goes up and down, but how do i stop it from doing a 360 turn.
aha sorry, this is what i have atm using UnityEngine; using System.Collections;
public class TurretControl : $$anonymous$$onoBehaviour
{
private int speed = 1;
void Update ()
{
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.UpArrow))
{
transform.Rotate(0,0,Input.GetAxis("Vertical") * speed);
}
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.DownArrow))
{
transform.Rotate(0,0,Input.GetAxis("Vertical") * speed);
}
}
}
this just allows me to use the up and down arrow keys to control the turret, i just want to be able to lock the turret @robertbu
Answer by Razouille · Mar 14, 2014 at 04:53 PM
Thanks so much, I have been trying to make a script to do this and it didn't work at all. I am so glad I found this.
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Multiple Cars not working 1 Answer
Need to limit the rotation angles on a turret 1 Answer
how to lock the z axis rotation 2 Answers
Play Sound when turret rotates 1 Answer