Y
Y
Yura Mailler2021-10-12 18:43:30
Unity
Yura Mailler, 2021-10-12 18:43:30

How to move an object forward despite Rotation?

Hello! I want to make the object spin, but also move forward.
Wrote this code

void Update()
    {
        transform.Rotate(0 , 0 , -Speed * Time.deltaTime); //вращение объекта  
        transform.Translate(Speed * Time.deltaTime, Speed * Time.deltaTime, 0); // движение вперед 
    }

The code works, but due to the fact that I change the Rotation, the object moves in the direction in which it is rotated and it turns
out that the object simply spins around its orbit, so to speak. how can this be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Loli E1ON, 2021-10-12
@Yura111

Read about Space.World
https://docs.unity3d.com/ScriptReference/Transform...

N
Nekit Medvedev, 2021-10-13
@NIKROTOS

Global coordinates to the rescue

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question