Hello, I've recently been developing a Mario & Luigi RPG styled platforming engine. The platforming system in of itself works fine, but the problem I have is with drawing shadows below blocks and the player itself. I should also mention that I'm using GMS 1.
Every object has a "root" that basically handles every collision on a flat x and y plain and compares the Bottom Z and Top Z of every object to see if they can move through one another. It draws the sprite of what it's supposed to represent above itself. So if the player's Z Bottom were -17 and the block in front of it's Z Top were -13, the player would be able to move forward.
The player object is the rectangular prism on the left. It's Z is currently at 0, and so is the shadow that's being drawn. I need to find a way to draw shadows in a way that will keep their depth in place, but also draw themselves under an entity like the player, regardless of whether the entity's depth is less than the shadow's. I'm using this to set each object's depth:
Z is the bottom most part of the object on the Z axis. The Z axis is always negative in this project, so that's why I put abs(z) there.
I believe that this is also a result of the shadow's depth being less than the player's
As you can see, the shadow is on top of the player.
Getting an object to draw everything in layers won't help due to the depth problem like in the second image. If the player were to stand on the shadow under the block to the right, the same problem would occur. Since depth is in play, simply raising the shadow's depth won't work and it will appear behind the lower red block due to the shadow's depth being lower.
Has anyone ever encountered anything like this or have an idea as to what I should do? I'm at my wit's end here. I understand this is a lot, but any help would be greatly appreciated. Thank you.
Every object has a "root" that basically handles every collision on a flat x and y plain and compares the Bottom Z and Top Z of every object to see if they can move through one another. It draws the sprite of what it's supposed to represent above itself. So if the player's Z Bottom were -17 and the block in front of it's Z Top were -13, the player would be able to move forward.
The player object is the rectangular prism on the left. It's Z is currently at 0, and so is the shadow that's being drawn. I need to find a way to draw shadows in a way that will keep their depth in place, but also draw themselves under an entity like the player, regardless of whether the entity's depth is less than the shadow's. I'm using this to set each object's depth:
GML:
depth = -(y+abs(z))
I believe that this is also a result of the shadow's depth being less than the player's
As you can see, the shadow is on top of the player.
Getting an object to draw everything in layers won't help due to the depth problem like in the second image. If the player were to stand on the shadow under the block to the right, the same problem would occur. Since depth is in play, simply raising the shadow's depth won't work and it will appear behind the lower red block due to the shadow's depth being lower.
Has anyone ever encountered anything like this or have an idea as to what I should do? I'm at my wit's end here. I understand this is a lot, but any help would be greatly appreciated. Thank you.