How can I make it so that my player only moves if there is no wall in the direction he wishes to move?

Hi guys. Long story short, I am working on a 3rd person game. The character rotates to look at the mouse, and moves up, down, left, and right while doing this. He is a rigidbody. Now whenever he collides with a wall object he jitters and bounces off it like crazy for as long as I am pressing the button. I don’t want this. I simply want him to stop. So what I’d like to do is somehow set it up so that player input will only move him in a certain direction if there is nothing blocking him.

Sounds easy at first glance, but the fact that he rotates around the Y axis to look at the mouse makes it much more complicated.

I would appreciate any help on this. Thank you!

You could use some Ray/Sphere/Capsule cast to detect whever there is a wall on the way of your player. See for example the documentation of Physics.CapsuleCast, which may be what you need for a character.

Note : These collision detection functions can selectively ignore some objects when looking for collisions based on the layer they belog to.