Instance creation not working

J

JadedFox

Guest
Hi there, long time user and lurker of GM. I'm currently having a problem with instance creation, none of the instance functions seem to draw to screen despite being in the draw method.

Here is my simple test code, which does not draw:

create_instance_depth(room_width, room_height, 10000, Obj_birds);

Create layer and add also refuse to work. Everything is compiling and the object is in the instance layer.

The only thing that has been changed is the version of GM used, I recently updated the version.

Thank you community!
 

AnotherHero

Member
Maybe it’s your positioning? You want it at the very bottom left of the room (outside the camera if you have one maybe?), below everything else?

Maybe on create have the object do a show_debug_message(“I’m here!”) to verify its creation?
 

Alexx

Member
Code:
create_instance_depth(room_width, room_height, 10000, Obj_birds);
Should be:
Code:
instance_create_depth(room_width, room_height, 10000, Obj_birds);
 
J

JadedFox

Guest
Hi there, thanks. My code is now:


instance_create_depth(room_width/2, room_height/2, 10000, Obj_birds);

if instance_exists(obj_birds)
{
show_message("I'm here!");
}

But the message does not show in debug and the object is still not created. I turned my antivirus off as a suggestion too, but nothing.

Regards.
 

Kezarus

Endless Game Maker
Maybe it's just a typo, but you are creating Obj_birds and are looking for obj_birds. This is case sensitive.

If you happen to have Obj_birds and obj_birds as object names I recommend that you change them, mate. This doesn't look good.

If one of them is a variable them please post your full code.

Cheers!
 
J

JadedFox

Guest
Hello, I've changed the name to simply "birds" but still no luck.

Regards.
 
Have you quintuple-checked all your spelling? The previous posts seem to show a casual disregard for the precision that is needed when programming. Make sure all references to everything have consistent spelling, including capitalisation. Also, as a sidenote, in your original post you refer to instance creation in the draw "method" (unsure what you mean by draw method, but I'll assume you mean draw event). Instance creation is unrelated to drawing and you shouldn't really be thinking of the two as linked (they are linked in a "soft" way, in that you need an instance to have that instance be able to draw itself, but that drawing is not related to the creation and 99% of the time you should not be creating anything in the draw event).

Code:
instance_create_depth(room_width/2, room_height/2, 10000, obj_birds);

if (instance_exists(obj_birds)) {
    show_message("I'm here!");
}
I cannot see a situation in which the above code does not display "I'm here!" as a popup message (I've corrected your original spelling). Even if something in the game is deleting obj_birds instances, that thing can only trigger after the show_message has already run. That's why I'm zooming in on the spelling issue, as I feel like that might be the most likely thing going wrong. Can you please let us know what event this code is running in?
 
J

JadedFox

Guest
Hello, that's it fixed. You were right Refresher, it was the wrong event. I've just come over from C++ so my concepts aren't fully integrated and I will need to be more careful with word choice and spelling.

Regards.
 
Top