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

GML Visual Create instance not working

Hi, I have something quite urgent to fix in my game but can't figure it out. Whenever I try to create an instance in any event, it most likely doesn't work. In the following pic, for example, the first instance (with the green checkmark) works, while the last one doesn't:

1631467126009.png
I basically am unable to create instances now, because they never show up, only some that I had from previous works are working. The things I tried:
1. Assigned a Key Pressed event to the object to see if it was there (only not visible) - didn't work, so I guess it is not even creating anything really;
2. Assigned different objects to the function to see if it had something to do with the specific object - it doesn't;
3. Disabled the Create Instance events that were working, to see if something about them was causing some sort of conflict - it isn't.

I'm very new to GMS2 and I need to solve this kinda urgently for a college assignment, so really any help is very appreciated. Thanks!
 

Ommn

Member
See other events, there may be a command to destroy the object.
you can show variable on screen to check if object is exists or not
like this instance_number(oBotaoRestart)
read more about instance_number
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Add a breakpoint to the event where you are haing the issue then run the game using the debugger. When you reach the breakpoint and the game stops, you can then step in to the DnD code and see if the instance is actually being created or not. Info here on breakpoints in DnD:

From what you show above, there is NO reason why one instance is being created and another is not, so something else is happening after the instance is being created.

PS: You have Draw actions along with the Instance Create actions, which suggests this all goes in a Draw Event... this would mean that every single frame of the game instances will be getting created using this code, which doesn't seem like a good idea...
 
Add a breakpoint to the event where you are haing the issue then run the game using the debugger. When you reach the breakpoint and the game stops, you can then step in to the DnD code and see if the instance is actually being created or not. Info here on breakpoints in DnD:

From what you show above, there is NO reason why one instance is being created and another is not, so something else is happening after the instance is being created.

PS: You have Draw actions along with the Instance Create actions, which suggests this all goes in a Draw Event... this would mean that every single frame of the game instances will be getting created using this code, which doesn't seem like a good idea...
Hi! first of all thanks for the last tip, it really wasn't a good idea. I tried to switch the instances order, the last one first and the first last. The error persists, the only one getting created is still the oFadeBlackGO. This is happening in other objects as well, even objects with no events other than this, like in the following image, it doesn't work:

1631538728135.png
 

Nidoking

Member
How are you determining that the instance isn't being created? Is it just not showing up? What if you look at the list of instances in the Debugger? Maybe you're just not seeing the sprite for some other reason that you haven't considered.
 
Top