- Home /
Rotating a spirit, right to left, how to limit rotation angel?
Hello
I have a 2D sprite image that i rotate right when moving right and left when moving left. The problem is that when pressing right or left too much the sprite round 360 while i want to limit it to 60 angel to each side.
Code used for rotating the image:
transform.Rotate(0,0,RightLeftSensitivity*controller.moving.x*-1f);
controller.moving.x is 1 or -1 i pressing right/left and 0 if not moving RightLeftSensitivity is speed value.
This code inside the Player.cs in the Update() function.
I am quite newb, so what ever i tried didn't work or made strange effects on the image.
Answer by drorriov · Sep 29, 2014 at 06:40 AM
Found this answer: Second example in the following link: http://docs.unity3d.com/ScriptReference/Transform-rotation.html
Your answer
Follow this Question
Related Questions
How to create sprites in unity at runtime ? 0 Answers
Can i change a ball with Rigidbody2D with CircleCollider2D to liquid on collision 0 Answers
2d rotation and translation issue 1 Answer
End game after livesLeft = 0 0 Answers
A node in a childnode? 1 Answer