T
T
TurnSpeedPotato2020-04-28 07:05:27
C++ / C#
TurnSpeedPotato, 2020-04-28 07:05:27

Rotate object y-axis by 90 and -90?

The question is probably stupid. There is an object, it must rotate to the right by n degrees, then to the left.

float r = 90f;
float l = -90f;
float angle;
transform.Rotate(0, angle * Time.deltaTime, 0);

How to prescribe conditions so that when a rotation of, for example, 90 degrees is reached, the object will turn in the opposite direction by a certain number of degrees from the original angle?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-04-28
@Makaroshka007

int dur = 1;

//...

if (angle > 90) {
    dur = -dur;
}
float r = 90f;
float l = -90f;
float angle;
transform.Rotate(0, angle * Time.deltaTime * dur, 0);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question