I’m trying to rotate an object 90 degrees around its centre over time however what I have currently rotates the object over time but it rotates over 90 degrees usually by 1 or 2 degrees. How would I go about making it rotate for half a second and exactly 90 degrees?
float rotY;
float targetY;
// Use this for initialization
void Start ()
{
} //Start End.
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown("w"))
{
rotY = transform.eulerAngles.y;
targetY = rotY + 90.0f;
}
if(targetY >= rotY)
{
rotY = transform.eulerAngles.y;
transform.Rotate (0, 90.0f * Time.deltaTime, 0);
}
} //Update End.
} //End.