K
K
Kirill Gopienko2021-10-17 17:58:06
C++ / C#
Kirill Gopienko, 2021-10-17 17:58:06

Why does Unity need Vector3 when infinitely rotating an object with transform.Rotate?

The question is probably stupid, but.
To create an infinite rotation of an object in Unity, you need to write transform.Rotate (...) to the Update function, but in order to multiply by a given speed, and time. delta time, you need to add new Vector3 in brackets, why in the first case you can just write down the parameters, and in the second one you need to specify new Vector3 to multiply by a variable, and by time delta time?

public float speed = 10f;

void Update()
{
    transform.Rotate(new Vector3(0,30,0) * speed * Time.deltaTime);
}

Thank you for your attention)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Loper47, 2021-10-18
@Loper47

You allocate memory for a vector.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question