yet another question on physics stuff…
I’ve got a simple scene with a cube and a plane.
The cube has a box collider and a rigidbody attached while the plane has just a mesh collider attached.
I made a simple script to make the cube slide on the plane, according to user input, that only applies forces to its rigidbody.
I used the following code to make it move on its forward direction:
float vaxis = Input.GetAxis("Vertical");
rigidbody.AddRelativeForce(speed * vaxis * Vector3.forward);
Drag and angular drag are set to zero.
Since there are no physic materials attached to any object in the scene and the physics settings are set to default values, I would expect the cube to slide in its forward direction without changing its orientation but this is not what I get.
Its rotation params slightly change and the result is that the cube is not moving straight forward, but is following a curved trajectory on the plane that I can not control.
If gravity is disabled on the cube or if I freeze rotation, everything works as expected but this is not a solution in my case.
Why is this happening? Am I missing something in the way rigidbody or physics works?
Any help is appreciated!
I forgot to mention that I set the cube’s rigidbody center of mass to (0, -1, 0) to make the cube slide and not roll…