D
D
Default_Nickname2022-03-08 20:54:30
C++ / C#
Default_Nickname, 2022-03-08 20:54:30

How to store rotation into a variable (Unity)?

It is necessary to somehow save the rotation along the z axis into a variable, please tell me how to do this?

Let's say: the object is rotated along the z-axis by 45° degrees, how can these "45 degrees" be stored in a variable?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TizZy, 2022-03-09
@Default_Nickname

float rotationZ = transform.rotation.eulerAngles.z

K
KraGen.Developer, 2022-03-08
@KraGenDeveloper

in short, how exactly with rotations xs, but if you really need Z in movement, then I do float posX = gameObject.transform.position.z;
this, push off from this and come to a decision yourself. It will be better for you)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question