I have a sprite which i want to only rotate 180 degrees from its central pivot, the code below is what i have so far, is there any way that i can stop the object from rotating once it gets from 0 degrees to 180 degrees and vice versa… i am new to all this so please keep it simple.
Hope someone can help.
function Update ()
{
if(Input.GetKey(KeyCode.RightArrow))
{
// Clockwise
transform.Rotate(0,0, -1.5); // --> Instead of "transform.Rotate(-1.0f, 0.0f, 0.0f);"
}
if(Input.GetKey(KeyCode.LeftArrow))
{
// Counter-clockwise
transform.Rotate(0, 0, 1.5); // --> Instead of transform.Rotate(1.0f, 0.0f, 0.0f);
}
}