GameMaker: Studio

GameMaker: Studio

View Stats:
Kapser1 May 15, 2014 @ 2:17pm
Assigning Variable To Created Instance'S Id from spawner object
I create an instance from a spawner object and try to set variables to the id of the instance. Since GM removed the function 'treat unitialized variables as 0', I need to set that variable in the object's create event.

However, it seem to overwrite what I set from the spawner object. The following code works to set the direction, which is a built in variable. However, it doesn't work for the other variables I'm trying to set.

spawned = instance_create(x,y,obj_sphere_1hit)
spawned.direction = spawn_direction // works!
spawned.canturn_timer = canturn_timer //don't work grrrr!

If I don't initialize the variable in the object create event it cause the game to crash.
< >
Showing 1-2 of 2 comments
Keys May 16, 2014 @ 3:41am 
There's nothing wrong with that code, the create event is executed before your 2 other variables, so that isn't the issue. There must be an error somewhere else.
Last edited by Keys; May 16, 2014 @ 3:41am
Kapser1 May 16, 2014 @ 11:55am 
Thanks. There was indeed an error. Fixed!
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: May 15, 2014 @ 2:17pm
Posts: 2