• 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] New Update Broke Depth System

Divinik

Member
I have a depth system based off of FriendlyCosmonaut's tutorial, and my implementation of it was working perfectly until the newest GMS2 update.

So every object affected by the system is a child of the object par_depthObject.

Here is the code for the depth handler object
Code:
var dgrid = object_depthGrid;
var inst_num = instance_number(par_depthObject);
var yy = 0;
var in_combat = 1;

ds_grid_resize(dgrid, 2, inst_num);

if battle_mode = false
  {
   with (par_depthObject)
     {
      dgrid[# 0, yy] = id;
      dgrid[# 1, yy] = y;
      yy++;
     }
  }
else
  { 
   with obj_testEnemy
     {
      if in_battle = true {in_combat++};
     }
 
   if instance_exists(obj_testCompanion) {in_combat++};
   if instance_exists(obj_testCompanion2) {in_combat++};
   if instance_exists(obj_testCompanion3) {in_combat++};
   if instance_exists(obj_testCompanion4) {in_combat++};
 
   ds_grid_resize(dgrid, 2, in_combat);
 
   with character_inUse
     {
      dgrid[# 0, yy] = id;
      dgrid[# 1, yy] = y;
      yy++;
     }
 
  if instance_exists(obj_testCompanion)
    {
     with obj_testCompanion
       {
        dgrid[# 0, yy] = id;
        dgrid[# 1, yy] = y;
        yy++;
       }
    }
 
   if instance_exists(obj_testCompanion2)
    {
     with obj_testCompanion2
       {
        dgrid[# 0, yy] = id;
        dgrid[# 1, yy] = y;
        yy++;
       }
    }
  
   if instance_exists(obj_testCompanion3)
    {
     with obj_testCompanion3
       {
        dgrid[# 0, yy] = id;
        dgrid[# 1, yy] = y;
        yy++;
       }
    }

if instance_exists(obj_testCompanion4)
    {
     with obj_testCompanion4
       {
        dgrid[# 0, yy] = id;
        dgrid[# 1, yy] = y;
        yy++;
       }
    }
 
   with obj_testEnemy
     {
      if in_battle = true
        {
         dgrid[# 0, yy] = id;
         dgrid[# 1, yy] = y;
         yy++;
        }
     }
  }

//Sort Rows
ds_grid_sort(dgrid, 1, true);
And here is the code for the objects affected by the grid:
Code:
var depth_grid = depth_controller.object_depthGrid;
if battle_mode = false
  {
   for (i = 0; i < ds_grid_height(depth_grid); i++)
     {
      if depth_grid[# 0, i] = id
        {
         depth = -250-i;
        }
    }
  }
else
  {
   for (i = 0; i < ds_grid_height(depth_grid); i++)
     {
      if depth_grid[# 0, i] = id
        {
         depth = transition_controller.depth-150-(i*5);
        }
    }
  }
It works perfectly accept that when battle mode is active, a single enemy does not display properly. I was debugging and noticed that the depth does change depending on the y position for the object, but it isn't drawn to show the change. Any ideas why this is happening? Thanks again.
 

Divinik

Member
Ok so I figured out the problem. It wasn't the update haha, it just coincided with me making a new shader for enemy selection. The shader was executed in an object with a high negative depth, so now the object's depth is set to the enemy's depth while drawing the shader.
 
Top