I have an isometric game that I have made a custom YSorting algorithm for. The code detects objects from a group of environmental objects that the player figure collides with, reads out their Z value and sorts the player in front of them. I have grouped all environmental objects in a group, for various reasons.
The code works well with one object in collision with the player. When the player is colliding with two or more objects at once, I would want the code to detect the object with the highest Z Order and sort it in front of that.
How do I pick the objects the player collides with and detect and determine the value of the highest Z order?