Hello! I've been encountering an issue in my project since at least November 2017, and I think I've finally come up with a novel solution! First, however, I must explain the problem. (You could read it in the link, of course, but I'll summarize it here.)
My project uses a Layer System, Collision Map, and Free Movement, all through scripts, to obtain a mapmaking system similar to parallax, free from the grid (mostly). I added more realistic aspects to my maps, including making the walls thinner than one tile so the player may walk behind them. The obvious consequence of all of the walls being a single image, of course, is that there's no way for the game to differentiate if you're in front of, or behind them. Whatever z-level you choose for that layer decides how it renders in comparison to you, and that's that.
I had an epiphany today, though. I can split the 'walls' layer into multiple images- one for each horizontal region of wall. Vertical segments cannot be walked behind (You can walk under them, in the case of doorways, but the player is always under these.), so there's no need for those. I thought,"What if the bottom pixel of the wall is on another layer, so the player cannot touch any of the wall layers from their front side? After arranging this, I could request a script that changes the player-character's Z-Level on contact with the wall layer, so they'll appear underneath of it!"
Here's a drawing to illustrate the concept.
The green boxes represent the player-character's hitbox, which can be customized with the Free Movement script linked above. Notice that the player-character in front's hitbox is in contact with the wall, but only the black line. This black line would be part of the floor layer, but still impassible, giving a buffer between the wall layer, and the player-character's hitbox.
Now that I've described this, the script I'm requesting needs to:
-Detect if the player-character, or an event's hitbox is making contact with a wall layer (The layer covers the entire map, so the script must be able to ignore empty space.).
-Change the player-character/event's Z-Level quickly enough that it won't disturb players.
-Events set to "Above Characters" would not be checked.
Any help, as always, is appreciated. I'm so very close to releasing my demo, so I just need to finish cleaning things like this up.
My project uses a Layer System, Collision Map, and Free Movement, all through scripts, to obtain a mapmaking system similar to parallax, free from the grid (mostly). I added more realistic aspects to my maps, including making the walls thinner than one tile so the player may walk behind them. The obvious consequence of all of the walls being a single image, of course, is that there's no way for the game to differentiate if you're in front of, or behind them. Whatever z-level you choose for that layer decides how it renders in comparison to you, and that's that.
I had an epiphany today, though. I can split the 'walls' layer into multiple images- one for each horizontal region of wall. Vertical segments cannot be walked behind (You can walk under them, in the case of doorways, but the player is always under these.), so there's no need for those. I thought,"What if the bottom pixel of the wall is on another layer, so the player cannot touch any of the wall layers from their front side? After arranging this, I could request a script that changes the player-character's Z-Level on contact with the wall layer, so they'll appear underneath of it!"
Here's a drawing to illustrate the concept.
The green boxes represent the player-character's hitbox, which can be customized with the Free Movement script linked above. Notice that the player-character in front's hitbox is in contact with the wall, but only the black line. This black line would be part of the floor layer, but still impassible, giving a buffer between the wall layer, and the player-character's hitbox.
Now that I've described this, the script I'm requesting needs to:
-Detect if the player-character, or an event's hitbox is making contact with a wall layer (The layer covers the entire map, so the script must be able to ignore empty space.).
-Change the player-character/event's Z-Level quickly enough that it won't disturb players.
-Events set to "Above Characters" would not be checked.
Any help, as always, is appreciated. I'm so very close to releasing my demo, so I just need to finish cleaning things like this up.