Constrain Unity Physics(New One) in DOTS not working [Answred]

I’m not sure why this is not working. It works for the most part but when I leave the ground by going over the edge of map the character is still tilted but by a very small amount. I looked through documentation and looked at components but I don’t see anything to constrain rotation.

 Entities.ForEach((ref MovementInputComponent movementInputComponent, ref MovementCharacterComponent movementCharacterComponent, ref PhysicsVelocity physicsVelocity, ref Rotation rotation) =>
            {
                // Get Current Velcity
                var currentVelocity = physicsVelocity.Linear;

                //Read Movement Input
                currentVelocity.x = movementInputComponent.input.x;
                currentVelocity.z = movementInputComponent.input.z;

                //Move
                physicsVelocity.Linear = currentVelocity;

                //Constrain Rotation
                rotation.Value = quaternion.EulerXYZ(0, 0, 0);
            });

physicsMass.InverseInertia = float3.zero;

2 Likes

If you’re using conversion, check the “Override Default Mass” toggle in PhysicsBodyAuthoring script, find “Inertia Tensor”, and set each axis you want to lock rotation around to “Infinity”.

1 Like

Wow this worked. Thank you so much.

Ok. Ill keep a mental note for that. I rather have my code just set it because I may want to allow rotation in a different type of movement and its easier for designers not to have to set things up. Again thanks for the help.