CharacterController - stop movement when colliding angled walls

My character always moves in straight lines on “rails”. So basically he has a path laid out for him, and he can only move along it in 2 directions (left and right)

So when my character moves and then hits any obstacle, I want him to stop moving in that direction completely. Even the character hits the wall at a narrow angle, I want him to stop moving forward immediately, but still be able to backtrack away from it, be able to jump over it.

The problem is, CharacterController’s normal behaviour is when you hit an angled wall the movement is projected along it, so the controller slides along that wall.

I thought about analyzing collisions and preventing movement, but I need to keep movement in other directions unhindered, and I don’t really know how to properly do that. I can think of several crummy ways to achieve what I want, but I thought I’d start by asking here.

I’ll try to bring this up once.