Hello all! I am new here. I'm attempting to do a simple 2D first-person game. I have images/sprites coming at me to simulate walking. Those are all in different layers. All those are selectable. The layers increase so that new objects/images/sprites are created in the horizon so they appear farther as they spawn behind the closest objects with the highest layer.

My trouble is when I try to select, with a mouse click, an object closer to me (from a first-person view) that has more objects behind, all those behind are selected too with the mouse cursor over them. From all the objects that the mouse cursor is on, I wanted to select only the one object that has the highest layer (the one that is closest to me). For example, I have an elephant at a close distance, a tree farther away, and a mountain on the horizon. They are all aligned in front of me. I click on the elephant but all 3 active objects are selected.

How can this be done? Thank you for any suggestions.