Cancel Input if the direction has a wall in the way

When my player roams the scene, I don’t want him continuously running into the wall, so how can i stop accepting input if a wall is in the direction of said input?

My goal is to prevent the player animations from continuously looping if he can’t go anywhere.

I think N3K has what I’m looking for in their MotorHelper script ( with KillVector, but they are using CharacterController’s properties to detect the “tokill” vector and I’m using Rigidbody.

Cast a ray in your character forward direction, and set a bool variable to keep whether you have a wall in your face or not. then set your forward speed to zero. also it can be used in any other direction.
set your animator parameters like (idle, walking, running) using character speed. so when you have a wall in your face, your speed set to zero and your running animation translate to idle.