Rotation is doubled on object?

I’ve been using Unity for about 4 years now but I’ve never seen anything like this. I’ve got an object and I’m moving it using transform.Translate(transform.forward * speed * Time.deltatime); like normal. It works when the rotation is set to zero.

But if I set the y rotation to 90, instead of moving to the right, it moves backwards. To get it to move to the right, I have to set the y rotation to 45. Any rotation I put on the object gets doubled when translating. Why does this happen?

The answer to all your questions is in the docs:

Basically - either use Space.World or use Vector3.forward instead of transform.forward.

1 Like

Still not sure what was wrong, but that worked. I thought having it relative to the world would make it move in the same direction no matter which way it was facing. Thanks!

The problem is you were using transform.forward which is a vector expressed in world space but you were using in a function that expected a local space vector. So the solution was just to either switch to a local space vector (Vector3.forward) or switch to a world space function (by adding the second parameter to transform.Translate).

You had apples and oranges before and the solution was to switch to apples and apples or oranges and oranges.

Ohhhhhhhh okay I see now. I just had it mixed up, I thought transform.forward was in local space and Vector3.forward was global. That makes a lot more sense, thanks