Preventing a player from moving past a certain point or object.

I have not been able to figure out how to stop my player object from moving in a direction when colliding with an object and/or a certain position.

Example.

Object A is moved right via mouse. Object A runs into Object B. Player should only be able to move Object A to the left now, as Object B should be impassable.

But what happens is Object A will simply push Object B out of the way and the player is able to keep moving to the right. How do I prevent this?

I have tried using the physics with ridged bodies and kinematic to no avail. Any help on this front would be appreciated. Thanks.

Have you looked at Colliders?