Why does object translation using its forward vector rotate excessively when assigning a new LookRotation, rotation or forward vector?

Basic stuff, I’m translating an object along the z-axis with:

   transform.Translate(transform.forward * speed * Time.fixedDeltaTime);

Then if for instance I hit a collider and I want to start moving in the colliders’ forward direction, to which I do:

   transform.rotation = Quaternion.LookRotation(collider.transform.forward, Vector3.up);

My object will be translating in a wrong direction. The test case I’ve set up has a translating object with an initial forward vector of (0,0,1) and the collider has a forward vector of (1,0,0) and after hitting the collider and rotating the object with above mentioned code, it starts translating in (0,0,-1) which confuses the shit out of me.

I get the same result if I just set the rotations or forwards to be equal, or if I use another vector than the forward vector to translate with.

I’ve had this difficulty with a few scripts for different purposes, so now I could really use an answer.

So Translate is using the local space of the object - therefore you need to be using Vector3.forward not transform.forward in your first line.

Apparently the whole ordeal was that I needed to specify that I was translating in world dimensions:

transform.Translate(transform.forward * speed * Time.fixedDeltaTime, Space.World);

God damnit :stuck_out_tongue: