• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker SOLVED: Please help me with depth sorting

Bee

Member
I am having one hell of a time depth sorting with an isometric game I'm making. Here's what I want:
- I have characters around 44x54 pixels
- I have objects ranging in size from 29x55 pixels to 100x100 pixels
- I want the characters to be able to walk slightly in front of objects so they layer over top the bottom of the object, and to walk slightly behind the objects so they layer behind

Here's how I have it set up:
- All characters and objects have depth = -y
- All characters and objects have an origin point somewhere in the middle lower half of the sprite (eg. the belt on a warrior, the middle of a trunk of a tree)
- All characters and objects' collision masks are rectangles that go from a bit below the visible part of the top to the bottom of the visible part of the sprite.
- Most sprites have transparent space around them to allow room for animations

And here's how it's working:
- Very rarely do they act like I want, but mostly the characters are able to walk on top of the objects when they should be going behind, and sometimes they go behind when they should be going on top. And it varies with the same type of object or same y positions.
- The obstacle code is working fine so that they can't walk through the objects

Is there some new way to depth sort that I don't know about or is depth = -y not suitable for what I want? Please help! This is making my game very unprofessional looking.
 

JackTurbo

Member
depth = -y isn't really sufficient for isometric projection as it doesn't take the x value into consideration when defining depth.

If I recall correctly I think my characters are working correctly with the following (although I would need to check to be 100%):
depth = -(x-y);
 
D

dirkinz

Guest
I've never made an isometric scene but I'd highly recommend you try placing the origin of the sprite right at the bottom where the sprite would meet the ground (for a person this would be the feet). If you imaging the game processing everything as if it were a top down 2d game but with a moved camera you see that the game will want to look at things relative to the floor, not some arbitrary plane floating above the floor.
 

Bee

Member
There, I found a tutorial on Youtube that deals with this. Looks like things changed with GMS2. It seems to be working now. Gotta do some tweaking though. Yay!!!! I thought I'd never get this.
 
Top