Infra red (IR) communication between objects

You need to say what sort of hardware you are using to detect and generate the IR.
there are two sorts of IR, modulated which is what the TV remotes use and un modulated which is (generally) what breaking beams use.

In this context you need to use a modulated beam so your objects need to emulate both the transmission and reception of TV like messages. You need a modulated receiver module to detect this as a straight IR photo transistor won''t do.

Then (and this is the hard part) you need to arrange a software protocol that arranges when to send and when to receive. Finally you need to work out what messages to send and what they mean.