Help with Z axis depth sorting

So i was trying to make a top down platformer where the platforms have a z position which the player can jump on the platform or go under the platform,
but the problem is the depth sorting, i'm using FriendlyCosmonaut's depth sorter instead of the "depth = -y", but my player sprite is always in front of everything.

OBS: i'm using the z axis project from Backspace Cadet.

--Depth sorter draw event
GML:
var dgrid = ds_depth
var inst_num = instance_number(o_nonstatic_par);

ds_grid_resize(dgrid,2,inst_num);

var yy = 0
with(o_nonstatic_par){
    dgrid[# 0,yy] = id;
    dgrid[# 1,yy] = y+z;
    yy++;
}

ds_grid_sort(dgrid,1,true);

var i = 0;
var inst;
repeat(inst_num){
    
    inst = dgrid[# 0,i];
    
    with(inst){
        event_perform(ev_draw,0);
    }
    i++
}
--Player Z Step event
Code:
//z jump (when space pressed)
if (zjump == true){
    z += zspeed /*z pos goes up*/
}
//if not ontop of block
if (!instance_place(x,y,o_block_par))
{
    zfloor = 0; /*zfloor is ground level*/

}
//if not on ground
if (!z <= zfloor)
{
    z -= zgrav; /*apply downforce on z pos*/
    zgrav += 0.2; /*grav gets stronger each step*/
}
//stop falling when you hit zfloor
if (z <= zfloor+1/*+1 for sticking glitch on ground*/)
{
    z = zfloor;    /*snap z pos to on ground*/
    zgrav = 0; /*stop applying downforce*/
    zjump = false; /*no longer in the air*/   
}
Here the example:
2020.04.09-10.05.png

I'm behind the block and yet being draw first.

So if anyone know the problem, please tell me.
 

TailBit

Member
Now, if the original draw event of the player is still active, and if it runs after your draw control object (cause of depth or instance creation order), then it will draw itself in front of everything ..

Maybe uncheck its invisible checkbox so it only draw itself when told to? That would be my first guess.
 
Now, if the original draw event of the player is still active, and if it runs after your draw control object (cause of depth or instance creation order), then it will draw itself in front of everything ..

Maybe uncheck its invisible checkbox so it only draw itself when told to? That would be my first guess.
Tried that and this is what happened:

2020.04.09-19.19.png

Also the draw gui has stopped working!
 
Last edited:

TailBit

Member
Which would mean that only the 2 Ps, the 0s and player are drawn by the depth system, the rest is not affected?
 
Which would mean that only the 2 Ps, the 0s and player are drawn by the depth system, the rest is not affected?
Its just one P, its a block that i can push

No the P is affected too (i forgot to add him to the depth parent), just the player isn't. Also the 0s are the background tiles.
 
Top