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.