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

Instance_create no longer accepts variables

O

Omninaut

Guest
The code is essentially:

(during attack frame)
{ var damage = instance_create(x,y,obj_damage)
damage.creator = id;
damage.attack = 5;
}

(in the damage objects create event)
z = creator.z;

The game crashes and gives me "<unknown object> <unknown variable> "creator" "z" error
 
Last edited by a moderator:

Slyddar

Member
The create code of an object will run first when the object is created, so the next lines are not ran until after the create code completes. So creator.z will be unknown at that time.

If you have code in your create that requires the variables you are passing to it, you should set an alarm so they get applied next step instead.
 
O

Omninaut

Guest
The create code of an object will run first when the object is created, so the next lines are not ran until after the create code completes. So creator.z will be unknown at that time.

If you have code in your create that requires the variables you are passing to it, you should set an alarm so they get applied next step instead.
Amazing! i knew that awhile ago and i guess just forgot it and idk. Thank you, fixed it immediately
 
Top