Collectable?

O

Owen Buckley

Guest
Just a simple question today, how would i make a instance destroy AND not re spawn when/if that room restarts?
 

TheouAegis

Member
You'd need to set a global variable. If that global variable is set, either don't spawn the instance or destroy it.
 
O

Owen Buckley

Guest
You'd need to set a global variable. If that global variable is set, either don't spawn the instance or destroy it.
I have my global variable that tracks how many are collected(within my "game" object, that obj is persistent), and then i have in my oCollectable object in the collision with oPlayer a global.collectable -= 1, and then a instance_destroy(). the problem is when i die and the room restarts, the collectable respawns and then i can collect it again.
 

TheouAegis

Member
I didn't say you needed a variable to track how many were collected, I said you need to track EACH ONE getting collected. The counter is fine for keeping track of how many were collected, but not for keeping track of which ones.

If the collectible is placed in the room manually, then in the Create Event check if the global variable specific for that instance has been set. If it has, call instance_destroy(). If the collectible is spawned via code in another object, then check if the global variable is not set before spawning the instance. Of course this means you'll need to make sure that global variable has been created before any of the collectibles can run their own codes.
 
Top