GML depth [SOLVED]

Discussion in 'Programming' started by Smallmak, Jul 10, 2019 at 9:47 PM.

  1. Smallmak

    Smallmak Member

    Joined:
    May 28, 2019
    Posts:
    15
    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
    };
    
    
     

    Attached Files:

  2. Smallmak

    Smallmak Member

    Joined:
    May 28, 2019
    Posts:
    15
    Please let me know if more information is needed
     
  3. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    887
    Is the origin of your sprite centered instead of at the feet while it is at the base of the tree sprite?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice