How do I remove Object 3 when Object 1 is touching Object 2?
What are the name of the classes?
How many of each could be in the world at any time?
With the answers to the above, include which object number is which.
Okay -- if the hero touches a monster, you want one of the keys in the world to be removed.
Unfortunately, it is not as simple and straightforward as it would seem with this:
if (heroTouchesMonster()) removeOneKey();
because the hero may be in contact with the same monster for several act cycles at a time, which could quickly remove all the keys from the world. So, if the monster touched is not removed from the world when found to be touching the hero, then you need to keep track of which monster is touching, so only one key is removed per monster touched (re-touching the same monster after separating from it counts as a new touch). In other words, you need to know when that first act cycle where a touch occurs happens. This requires that you hold the monster being touched in a field until you are not touching it (where you set the field to 'null'). If the field is 'null' and a monster is found to be touching, then it is first act cycle to be found touching and the monster is stored in the field and a random key removed from the world.