Legacy GM despawning life expansions.[solved]

I have an item that functions has heart pieces in zelda, collect 2 and the player's health increases. I've created the item, but returning to the room after going to another respawns them.
I have the object destroys itself when
global.heartcontainer1=true
But then I need to flag each heart container to trigger that global variable.
I tried giving the giving the global variable, a normal variable that should be able to be adjusted in the creation code. but I don't seem to understand it.

heart piece
Code:
//create event
despawn=0 //global.heart1

//colision event
despawn=true

//heartpiece creation code
if global.heart1=true{
instance_destroy()}
the heart pieces do self destruct properly if I change the global variables manually. but I can't figure it out how to trigger it from collecting the item.
 

TheouAegis

Member
Instance Creation Code for each heart piece:
value = //put a unique sequential number here//
if global.collected[value] == true instance_destroy;

Leave the create event empty.

Collision Event:
global.collected[value] = true;
instance_destroy();

In your global variable initializing room:
global.collected[20] = 0;

Change the 20 to however many hearts and whatever else you have.
 
Top