Distance is about 3m. IR or visible light - does not matter.
It is possible that object/obstacle can be shiny, so for correct detection necessary large amount of reflected light.
Maybe for this task better to use specific retroreflector?
UPDATE:
there will be two sensors with distance about 3-4 cm between. Object must cross 1st sensor's reflector but do not cross the 2nd one.
The scheme of this sensor should be this:
But the use will be this: