- Home /
90 Degree Smooth Rotate On Button Press
Hello guys. I'm making a simple grid system. When i press the A or D button my character turns left or right 90 degree. (Y Axis) Everytime i press the key it adds 90 to my Y axis. So, 0-90-180-270-0. But this happens instant and it hurts your eyes after sometime. Is there a way to rotate my object smoothly 90 degree everytime i press the key?
Let's say my object's Y axis is = 90 I pressed D to turn right, so it needs to be = 180 And it will rotate my object from 90 to 180 in 5 seconds. Like this maybe :D
Thanks for helping!
Answer by mj321 · Aug 30, 2016 at 03:06 PM
It works really good thanks! Is there a way to make another one but turn -90? Btw, can you please inform me about how this works? Thanks!
StartCoroutine( Rotate(Vector3.up, 90, 1.0f) );
You can adjust the three parameters passed to the Coroutine. The first is the axis for the rotation. The second is the angle. The third is the duration in seconds.
Your answer
Follow this Question
Related Questions
pressing button enables motor forever? 2 Answers
Button Press and Hold Animations 0 Answers
Smooth Mouse Orbit c# 2 Answers
Press Any Key To Continue 0 Answers