• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Changing depth causes unexpected behavior

P

psyke

Guest
So, I found something that is really bothering me, it might be a bug, I don't know.

Look at this code:
bug.jpg
This code creates a new enemy and attachs it to the monster from the top, as you can see in the screenshot below:
bug_4.jpg

Everything was working fine in GM 1.4, but when I ported my game to GM 2, this error started to happen:

bug_2.jpg

This is the event where the error happens:
bug_3.jpg

If I remove the line: "Load.depth += 1", it stops causing the error.
Sorry if I was not clear, this is something really strange and I don't know what is happening.
 

Tthecreator

Your Creator!
If you remove the line "Load.depth += 1", then is the variable Corpse at line 6 inside gmlObject_objUnit_other_10 still equal to -4?
 
P

psyke

Guest
If you remove the line "Load.depth += 1", then is the variable Corpse at line 6 inside gmlObject_objUnit_other_10 still equal to -4?
Man, I think you nailed it.
When I started reading your comment, something came to my mind:

If I change the depth of the monster, it will move the instance to a temporary layer (with NO NAME).
The Corpse uses the LAYER of the Owner, I think that's why it's causing the error. I will try to create the corpse using DEPTH instead of LAYER.
 

Tthecreator

Your Creator!
@psyke Yea, I've also had problems porting over some stuff to the new way depths work, but got it running eventually.

Just let me know when you fixed it!
 
P

psyke

Guest
@psyke Yea, I've also had problems porting over some stuff to the new way depths work, but got it running eventually.

Just let me know when you fixed it!
Yep, that was the error after all:
bug_5.jpg

I replaced the AddObject function to a new function called AddObjectDepth, instead of passing the layer to the Corpse, it passes the depth. Now everything is working fine =)
 
Top