I want to know how to make an object rotate when I move the mouse up and down. How can I do this? Thank you.
Check this: http://unity3d.com/support/documentation/ScriptReference/Input.GetAxis.html
I’m pretty sure you can learn from that piece of code ![]()
Hehe thanks for the fast reply. I’m not a nub or something, just haven’t any idea about how to do it :L
Can I make something to limit the rotation? Like, make it rotate just 180 not 360.
Hehe, don’t worry.
You can use the Input.getAxis(“vertical”) to get how much the mouse is moving.
This method return a float between -1 and 1.
Then you multiply that value by the rotation’s speed you want.
Finally, use the transform.Rotate to rotate the object along the axis of your desire, with the angle being the mouse movement X your speed;
Yes I get that. But when I move the mouse to the top of the screen and go left, the object rotates to left(btw, I’m using it in a platformer)
If you’re only using Input.GetAxis(“vertical”), then double check if you’re rotating over the right axis.
Thanks for the help I solved the problem!