Rotating Physics with Gravity

I am new to Unity and I’m not sure if this is the right forum to post in. I’ve figure out how to add the component Rigidbody. I have a new cube spawn at (0, 10, 0) any time I press the space bar, when it hits the ground, due to gravity, it’ll rotate. I don’t want it to rotate unless it’s been hit from the side. Also I Want it so it can only rotate in the x direction. My goal is to make the blocks stack on one another without them rotating in any way unless they are hit from the side. Even then I only want them to rotate on the x axis as if they were surrounding by two walls.

Well, give them this in their Update() function:

transform.eulerAngles = Vector3(transform.eulerAngles.x, 0, 0);
rigidbody.angularVelocity = Vector3(rigidbody.angularVelocity.x, 0, 0);

They shouldn’t shift too much when hitting the ground, but you can also add an OnCollisionEnter() condition that sets the angularVelocity to Vector3.zero when they hit the object tagged “Ground.” You’d have to add the tag, of course.