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

Question - Code Instance_Create_Depth Small Issue

W

_Why

Guest
Why doesnt instancec_create_depth(x, y, o_example, 0); throw an error?

I thought GMS2 was just spitting out the wrong object for whatever reason. It wasnt until after I checked the manual that I realized that I got the depth and object variables switched.

A small issue for sure, would be nice to have though. (Atleast for me.)
 

The-any-Key

Member
try:
show_debug_message(string(o_example))
and you will get the output (just an example. You will get another number :))
56

All objects, sprites, sounds, paths, instance id, data structures....
is just numbers (reals)

so you just tell gms2 this:
instancec_create_depth(10, 10, 56, 0);
And thats all ok. The "0" that is the object is the first object in the project.
 
instance_create_depth(x, y, depth, obj);

depth first, then object.
... It wasnt until after I checked the manual that I realized that I got the depth and object variables switched.

A small issue for sure, would be nice to have though. (Atleast for me.)
This is a logic-error, and would only throw an error if you used a 'depth' that was an invalid object index (ie. -10). As the first reply said, objects are indexed as numbers, so everything is working as it should. You can even use object indexes for x, y.
 
Top