E
E
Evgeny Ivanov2021-07-12 09:15:44
Unity
Evgeny Ivanov, 2021-07-12 09:15:44

How to smoothly rotate an object (code doesn't work)?

It is necessary to smoothly rotate the object along the x-axis (horizontal) by pressing the button.

Here's a working code that will sharply rotate an object.

public void RotateIt()
{
GameObject imageCharacter = GameObject.Find("Image-Character");
imageCharacter.transform.rotation = Quaternion.Euler(0, 180, 0);  // Резкий поворот. Работает.
}


Here's a gentle twist
public void RotateIt()
{
GameObject imageCharacter = GameObject.Find("Image-Character");
imageCharacter.transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 180, 0), Time.deltaTime); // Плавный поворот. Не работает.
}

Smooth turn code with no syntax errors, but nothing happens when the button is clicked.

How to smoothly rotate an object?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-07-12
@freeExec

Here's a gentle twist

But it is necessary in Updateand not just like that. You also need to be able to copy examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question