- Home /
Question by
CrilleStyles · May 02, 2014 at 05:23 PM ·
rotate objectclamped rotationrelative rotation
Rotate object to a certain rotation if key press
How do I make a object rotate to just X=20 if Lshift is pressed and then go back to X=90 if Lshift is released?
Comment
Answer by sumeetkhobare · May 02, 2014 at 05:48 PM
if(Input.GetKeyDown(KeyCode.LeftShift) {
transform.rotation = Quaternion.Euler(20,0,0);
else
transform.rotation = Quaternion.Euler(90,0,0);
Mark question as solved by this answer, if it solves your problem.
To finish this script off change it to this: function Update () {
if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.Q))
transform.rotation = Quaternion.Euler(0,0,0);
else
transform.rotation = Quaternion.Euler(0,0,0);
}
and change the 0, 0, 0 to whatever you WANT!
and what if i wanted to put this on my camera? i wanted to make quake-like strafing