Hey everyone!
Have been sitting here trying to solve a problem but I can't figure it out. I am building a tower defense game where I have a laser tower. I can build this laser tower on several building spots and if you build it next to another tower then occasionally the laser overlaps the tower next to it. When the laser then follows the object it is shooting at, it appears under the whole tower (see attached pic).
I want the laser to change Z order so that it is above the tower it is overlapping that is not a part of its container.
I have tried several solutions. I have an instance variable that I assign on creation so the laserID is set to the tower cannon UID, and I was thinking that if the laserID is not equal to the tower1cannon UID then on overlap it would put the laser above that cannon (see attached pic of events). But I can't figure it out. I have only tried to solve this for the same tower type.
My dream scenario would be to find a solution that solves this problem so that the laser won't go under any of the 5 towers that are buildable in the game.