• 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!

GML depth [SOLVED]

S

Smallmak

Guest
Why is my depth sorter working for some object and not for other object? for example the below code makes it so my character appears in front of and behind npcs but Is not working for trees. I have made sure that the tree is a child of parent_depth object

Code:
//Resizegrid
var inst_num = instance_number(par_depthobj);
var dgrid = ds_depthgrid;

ds_grid_resize(dgrid, 2, inst_num);

//add instances to the grid
var yy = 0; with(par_depthobj) {
   dgrid[# 0, yy] = id;
   dgrid[# 1, yy] = y;
   yy += 1;
   
};

//sort the grid in ascending order
ds_grid_sort(dgrid, 1, true);

//loop through grid and draw instances in order that has been set
var inst; yy = 0; repeat(inst_num) {
   //pull out an ID
   inst = dgrid[# 0, yy]
   //draw yourself
   with(inst){
       event_perform(ev_draw, 0)   
   };
   yy += 1
};
 

Attachments

Top