Player does not fall down from block

Hello guys, I have recently come across a certain problem I am not able to solve myself. My character has BoxCollider on it and it also has Rigidbody.

The problem is that when I try to leave the block the player is currently standing on, I become stuck on the block and I am not able to leave it. I checked every BoxCollider whether it somehow interferes with the player’s colliderbox, but everything was just fine.

After certain time, I found out it was happening because I tried to fix Z rotation, so the player couldn’t roll while moving horizontally. But this also disabled the ability to fall from the block because you have to rotate first to fall down.

Any idea how am I supposed to fix it? Here’s the code that actually does the problem, but is necessary to avoid rolling on the block like mad.

Quaternion q = transform.rotation;
q.eulerAngles = new Vector3(transform.rotation.x, transform.rotation.y, 0);
transform.rotation = q;

Hi gegem,

I wonder if you have the same problem if you freeze the z-rotation of the Rigidbody component itself (by activating the dedicated checkbox on the RB in Inspector) and get rid of the code you posted.

1 Like

Thank you, DrDigg0R!

It actually worked. The problem is I didn’t even know this feature is in Rigidbody component. Thank you for your time, at least I know more now. Solved.

@Gregel Thanks for your reply, glad it helped!