My player has a rigid body with frozen constrains on all rotations, but somehow when my player hits the ground, a building, or any other collision, he gets smashed to the ground, with a result of my camera and position of the player messed up. I want him to only move along the x, y and z axis, and no rotating, any idea’s?
If you’re really desperate to keep its rotation constant, you can add
rigidbody.rotation=new Quaternion(0,0,0,0);
to the “Update()” of a script attached to the player (with whatever rotation you want).
transform.LookAt(transform.position + new Vector3(x,y,z));
has the same effect looking in an arbitrary direction (code in C# and easy to convert).
Before anyone marks this answer down for being horribly inefficient I’ll attach a warning to it: it sets the rotation in every frame. But if it is just for the player, as suggested, that’s only one Rigidbody and therefore it’s computationally not much of an issue. But don’t go about attaching this to every character in the game. That might not end well…
Hope that helps, and mark the answer as correct if it does. Tell me how it goes!