• 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 How to find where/when a variable changes?

FacesOfMu

Member
Hi all,
I've got an object that seems to change it's layer to -1 at some point and I can't find out where this happens. I've tried searching all uses of the word "layer" in my code to see what each line does, and nothing seems to indicate where the change is happening. I've even added a debug string to the object's step event and I can see when it changes, I just can't find where in my code this happens.

What can cause an object's layer to become -1, and is there any way of finding out what line of code changes it?

Cheers!
 
B

Bayesian

Guest
From the Docs
IMPORTANT! if you have created the instance using the instance_create_depth() function, or have manually changed the depth variable, the layer assigned to the instance becomes a "managed" layer, which is one that GameMaker Studio 2 controls and manages automatically. In these cases the layer variable will return -1.
 

FacesOfMu

Member
Found the solution: the layer docs page says:
Code:
IMPORTANT! if you have created the instance using the instance_create_depth() function, or have manually changed the depth variable, the layer assigned to the instance becomes a "managed" layer, which is one that GameMaker Studio 2 controls and manages automatically. In these cases the layer variable will return -1.
I tracked down a line where the depth was set manually with a "depth =" and voila, all fixed.
 
Top