Smoothly Rotate 2D sprite 90 degrees on click

Hey Unitarians,

I have a simple 2D square in my scene, and I want it so that whenever the user clicks the screen, the square rotates itself 90 degrees to the left. I want it to smoothly rotate over a span of half a second.

So far, I can make the square rotate 90 degrees to the left instantaneously by using transform.Rotate (Vector3.forward * -90f);, but the problem is that it does that instantly, and not smoothly over a period of half a second

I tried using Quaternion.Lerp, but it doesn’t work. It turns one degree and then stops and won’t turn again when I click it. Also, before I clicked for the first time, there were error messeges that complained of the transform.rotation assign attempt being not valid. I have never used Quaternions nor Lerps before, so I don’t know how it works at all.

I don’t want to use the above methods. I have no idea how to make it work. If anyone could help me, it would be a godsend.

Thanks in advance,
Aman Jha

try using Time.deltaTime

Why don’t you try using something like iTween?