- Home /
How to rotate 90 degrees
function Update() {
if(Input.GetKeyDown("D")) {
transform.rotate += 90
}
I'm not actually in unity right now but I just wanted to know if it would look something like this. I'm working on a project for a game for the blind.
Answer by pickle chips · Jun 16, 2013 at 01:04 PM
It depends what exactly you want it to do. If you just want it snap to 90 degrees, with no smoothing, then this is what your code should look like
if (Input.GetKeyDown(KeyCode.D)) {
transform.Rotate(0, 90, 0);
}
It depends. $$anonymous$$eycode can be used if The game is only going to be using a computer (with a keyboard), and you don't want the user to configure the controls them self. It's just simpler since you don't need to use the input manager.
But, if you do want it to be able to use something other than a keyboard, or you want the user to be able to change the controls, then use "D", with the input manager.
I just used $$anonymous$$eyCode.D out of habit, but "D" might be a better option.
Answer by Graham-Dunnett · Jun 15, 2013 at 08:50 PM
I've already seen that but I wanted to know if I'm doing it right.
Answer by Kirbyrawr · Jun 16, 2013 at 12:24 PM
You are not specifying the Vector or the axis... So what you want to rotate?
Answer by Griffo · Jun 16, 2013 at 12:51 PM
Try this X,Y,Z
if (Input.GetKeyDown ("3")){
transform.Rotate(Vector3(0,90,0));
}
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Texture2d.Readpixel slow down performance while stand-alone exe is minimize 0 Answers
Fade in Fade out in unity 1 Answer
Hide the ImageTraget in Real world 0 Answers