(SOLVED) Rotating using Space.World

I’m kinda embarrassed to ask this, but I can’t figure this out:

I’m moving a cube’s Z position like this: (C# code)

currentTransform.Translate (new Vector3(0f, 0f, crashSpeed * Time.deltaTime));

While I’m moving this cube over the screen like that, I want it also to rotate, like this:

currentTransform.Rotate (0, 20 * Time.deltaTime, 0, Space.World);

It rotates all right, but unfortunately it also moves in the direction it’s rotating to. I don’t want this. The cube must move in a straight line over the Z axis, while rotating. So I tried switching between Space.World and Space.Self, but this doesn’t have any effect.

What am I missing here? Help is much appreciated.

Thanks!

Your rotation code actually has the answer to your problem: you need to make the movement relative to Space.World too. Currently it is in object space so if you rotate the object, the z direction in object space will change too.

You’re right! :shock:

Thanks very much for solving this puzzle for me. :smile: