Not allowing the character to fall after collision

Hi everyone,

I have a character moving in a maze. It moves using transform.Translate and rotates on the y-axis using transform.Rotate. But, when my character collides with a wall, it falls on the x-axis or the z-axis. It has a rigidbody and its constraints are on the x and z axis for rotation. After falling down, it shows some weird behaviour after pressing the arrow keys. Is there anyway to avoid my character to fall or just keep the rotation of the x and z axes 0.

EDIT:

Let me be a bit more precise. I made number 10 using cubes. The cubes are the child objects of an empty gameObject. I attached the Rigidbody to the empty game Object but nothing happened. I also added a box collider but still nothing happened.

Any help would be appreciated.

Thank you.

Make your rigidbody kinematic or freeze rotation. Anything would be fine.