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

GameMaker How to make it so picking up one item does not destroy every instance of it.

C

Chris12245

Guest
I currently have it set like this, but of course doing this destroys every instance of that object in the room. I was wondering if any one has any tips of how to do this.
with(oPlayerPistol)
{
if(distance_to_object(oAmmoBox) < 10) and (key_interact)
{
ammo = ammo + 5;
instance_destroy(oAmmoBox)
}
}
 

mar_cuz

Member
You need to get the instance id of the ammo box.

Try this:
with(oPlayerPistol)
{
if(distance_to_object(oAmmoBox) < 10) and (key_interact)
{
var box = instance_nearest(x, y, oAmmoBox);
ammo = ammo + 5;
instance_destroy(box);
}
}
 
Last edited:
Top