H
H
hipa2021-11-02 19:00:20
C++ / C#
hipa, 2021-11-02 19:00:20

How to stop the rotation of an object?

I have this line of code
this.transform.RotateAround(new Vector3(positionX,positionY,positionZ), new Vector3(0f, 0f, 1f), 360f * Time.deltaTime);
which rotates the object relative to a given point, with a certain speed. And I need the line to rotate by a certain number of degrees. (90)
if (transform.eulerAngles.z == 90) { code }
This option does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crebor, 2021-11-02
@Crebor

Quaternion target = Quaternion.Euler (0, 0, 90); 
transform.rotation = Quaternion.RotateTowards (transform.rotation, target, Time.deltaTime * 500);

So try. So I rotated the camera in my game by 90 degrees.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question