Bear with me, please...I'm going to try to articulate the set-up and the problem in as clear and brief a way as I can...but I sometimes struggle to do both.
PREMISE:
My game, "Mr Spy", is set in a 2D platformer environment where Mr Spy (hereafter, "Spy") must move stealthily through an office environment to complete his mission. The game is inspired by the classic arcade game, "Elevator Action". However, I'm taking the use of the multiple doors in the original game to a whole other level by making it to where you can enter the doors and explore additional hallways and office rooms.
SET UP:
The game levels will be comprised of three sections:
1. The main hallway which is almost completely unobstructed from end to end...not unlike your traditional platformer like the Super Mario Bros. series. The Main serves as a kind of "hub" for all other rooms and hallways connected to it via the doors.
2. Backrooms or parallel hallways. *
3. Front rooms or parallel hallways. *
* The back and front rooms (or hallways) all run parallel to the main hallway. Entering a door will take you to the front or back areas depending on which door you enter. The layers I have - besides being set up for background and foreground objects and such - are situated to so that layers in the front or back of the main hallway serve as the back or front rooms (...or hallways...you get the idea).
From the image above, you can see how I've grouped all my layers together to essentially act as slices of theoretical "group layers". The main "group layer" has two layers for the doors that lead to the back and to the front group layers (which amount to the front and back rooms). Each of these grouped layers I've assigned a "LayerDepthLevel" - 0: back, 1: main, and 2: front. The main, of course, has two doors that lead away from it. Spy also has a LayerDepthLevel variable assigned to him, as well. This is to identify that Spy is in the same layer group as the door he is trying to use. That way, if Spy is overlapping a door in the front group layer but he's all the way in the back, he can't use that door. Each Door is also assigned a "MoveSpyToThisLayer" variable so that, when conditions are right, each door assigns to Spy which layer he's supposed to be moved to. (This assignment of values is set up at the Start Of Layout and is tested by which layer the Doors are on to begin with. I try to set things up so that I have to do as little manual work as possible given that there will be tons of doors throughout the game.)
I have four types of doors grouped together in a Family (Doors) - they all act essentially the same but are specifically created for each layer they are found on. But this is where the problem begins...
PROBLEM:
When moving between layers - from front to main or main to back or vise versa - there will be two doors that overlap each other. These two doors are separate objects that, as described above, serve the same function. I want to make it so that when overlapping these two doors, they both open as if they were one door (because it would look weird if one door animated opening but the other door remained closed when peeking through the first door). However, only the door that is on the same LayerDepthLevel should be referenced when deciding how Spy should move from one layer (and LayerDepthLevel) to the target layer.
This is my current event sheet...
I'll try to explain what's going on per event line #...
70 - Check if Spy is overlapping any of the four door objects (as found on the four layers designated for the doors)
71 - Determine if the doors being overlapped share the same LayerDepthLevel values. Meaning, while the doors and Spy may be on different actual layers, are they part of the same layer group? If yes, proceed... (The OverlappingDoorActive boolean is for another feature and not relevant here.)
72 - If the DoorInUse value is false, meaning that Spy (nor any enemies) are not using the door and that the door is done with its open/close animation, when the player presses A make it so Spy cannot move (he's about to "walk through" a door, after all), set the DoorInUse boolean to true so that the door cannot be used by any other characters and that repeatedly pressing A cannot prematurely trigger any other action, and set the Door animation to "Opening". (The ActionAvailable boolean is not relevant here.)
NOTE: There are two door objects in question when moving to and from a back layer group and main, and to and from a main layer group and front. The best way to understand this is with this sketch I did...
Each door pair is what links the front to the main and the main to the back layer groups. This is important to understand for the next set of event lines.
73 - Pick the Door that has the same LayerDepthLevel value as Spy and check for when that Door has the animation frame value of 9 (halfway through the animation). Move Spy to the destination layer that Spy should be on when moving through that Door (and update Spy's new LayerDepthLevel value accordingly). However, there are two Doors still being overlapped at this point which is why it is necessary to use a Pick By Comparison at this point.
74 - For another feature, thus irrelevant.
75 - Once the Doors have finished their animations, set them to useable again and update their animation.
HOPEFULLY, that extensive breakdown sets all things clearly as to what is SUPPOSED to happen. The problem is that when the two doors are overlapping each other, the intended action of the door opening, Spy going to his target layer (and all values updating), and the doors closing to be used again does not actually work. When I have the doors NOT overlapping, Spy can go through a door, end up on the correct layer with the correct variable values, and then use the OTHER door to return back to his originally starting layer and everything works. It is only when the two doors (acting as one as I intend them to) are overlapping does NONE of this work.
For some reason, I suspect, the issue is that event line 71, but I cannot figure out what's the actual deal and why it's not working.
Can I get some expert insight, please, to help me figure this out? Thank you!
(EDIT: I don't know why my last image appeared rotated like that... Mentally rotate 90* counter-clockwise to see it correctly.)