Alexir
Member
I have an isometric/top-down game with objects that I want the player to walk in front of and behind. When they walk in front of it, the player is visible and obscures the object behind it partially. When they walk behind it, then the object in front of it obscures the player from the camera view. This is all pretty standard stuff and I have got a good bit of code that makes this work successfully for a fence object;
STEP:
if instance_exists(obj_Player) && obj_Player.y >= self.y
{
depth = 1
}
if instance_exists(obj_Player) && obj_Player.y <= self.y
{
depth = -1
}
(Take in mind the fence's origin must be at the bottom for this to work)
Now this works perfectly fine, but when I have two players, this breaks completely. Either both players are behind the fence, or both players are in front of the fence, despite their position. This is obviously not good and I need a way to have one player be on one side of the fence, and the other player on the other side. Any help would be appreciated.
STEP:
if instance_exists(obj_Player) && obj_Player.y >= self.y
{
depth = 1
}
if instance_exists(obj_Player) && obj_Player.y <= self.y
{
depth = -1
}
(Take in mind the fence's origin must be at the bottom for this to work)
Now this works perfectly fine, but when I have two players, this breaks completely. Either both players are behind the fence, or both players are in front of the fence, despite their position. This is obviously not good and I need a way to have one player be on one side of the fence, and the other player on the other side. Any help would be appreciated.