Okay I’ve nailed it all down to an issue that looks like a bug. To reproduce it, simply create any 3D objects eg. a cube in an empty project, set its Y rotation to anything else than 0, add a rigidbody and a new script. In the script’s Start (or Update) method, simply write:
transform.up = transform.up;
Obviously, this will change nothing, right? Wrong. If you view the cube falling from above, you’ll see that its Y axis gets reset to 0 degrees as soon as you start Play Mode.
This issue is present for all axes. For example if I have an object traveling in direction Z, with a Z rotation different from 0, that Z rotation gets zeroed on startup if my scripts Update has:
transform.forward = transform.forward;
This somehow then evolves into a more general problem, for example I can’t keep my forward moving object’s original Z angle, it gets zeroed just like above, as soon as I set the object to face the direction of its velocity with
transform.forward = transform.GetComponent<Rigidbody> ().velocity;
In my game, as the object that should at certain moments start to follow the direction of its own velocity is the parent to the first person camera, this means you’ll see the camera view angle making instant rotations which looks awful.
Anyone knows if this is indeed a bug I should report or maybe there’s something I’m missing that explains it?
Any workaround?