Sliding A Box Around With Physics

Imagine the roll-a-ball tutorial, except in this case I’m attempting to slide a rectangular box (standing on its smallest face [think humanoid shape/orientation]) around using WSAD. Here are the rules I’m trying to adhere to:

  • Movement is applied via forces “transform.GetComponent().AddForce()”
  • The box should only slide on the ground and never rotate as a result of the applied forces
  • The box can’t have rotation frozen, because it needs to be knocked over when colliding

Hopefully that gives you some idea of what I’m trying to do. Essentially, the issue I’m having is that if I restrict rotation for the X and Z axis I get the movement I want (the box doesn’t tip over simply by moving it with WASD), but if I run the box into something that should knock it over it can’t because the rotation is restricted. How can I achieve all three points above?

Thanks in advance!

This might not be the best way of doing it but it is the best I could think of.
So I’d freeze the rotation at the start, and add the forces to move the box like usual.

So to add the rotation what you can do is add some code which checks if you have collided it will unfreeze the rotation, and another which checks if you are not colliding and your rotation are NOT frozen, it will freeze the rotation.

I would have provided a script but I tend to work with 2D things.

Hope this helps!