Hello there! I searched for days now and can’t seem to find what I am really searching for…
I want to roate an object in Unity 90 degrees, by clicking on it. And I did and it works, the problem is that I want to “show” the movement to the player, and not have the object be 0 degrees on frame 1 and 90 degrees on frame 2. I want the object to gradually rotate to 90 degrees. I want to “animate” the movement, although without using animator on the object.
I used Time.deltaTime and it didn’t rotate gradually(maybe I am using it somewhat wrong?)
Any help would be highly appreciated!
Heres with what I am working with (code)
private void Update()
{
if (!completion) //checks weather the picture is completed, if not, it lets you click
{
if (Input.GetMouseButtonDown(0)) // checks weather you hit the left mouse click
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100.0f)) // checks if it hits the object
{
if (hit.transform != null)
{
PrintName(hit.transform.gameObject);
hit.transform.Rotate(0f, 0f, 90f); // rotates the clicked tile 90 degrees
//hit.transform.Rotate(0f, 0f, 90f * (Time.deltaTime * rotateSpeed)); //doesn't show the movement
}
}
}