Jump to content


Photo

Multiple destroy


  • Please log in to reply
1 reply to this topic

#1 Darkadin

Darkadin

    GMC Member

  • GMC Member
  • 89 posts

Posted 04 March 2012 - 05:43 PM

I have a controllable character using the arrow keys i can move, and i have some enemies that follow me slower than i move, i also have some traps on the floor and the way i have the trap set is that it fades in and then has a timer till it blows. I have this little code for if an enemy gets caught near it it destroys the enemy
i=instance_place(x,y,argument3)
if distance_to_object(i)<5
{
with (i)
{
instance_destroy()
}
}

so it works with one enemy but if two enemies land walk over it as it explodes only one enemy will destroy, anyone know why?
  • 0

#2 thegame

thegame

    Flying Penguin

  • GMC Member
  • 1404 posts
  • Version:GM:Studio

Posted 04 March 2012 - 06:59 PM

instance_place only returns 1 instance, so only 1 argument3 will be returned.
To get all of them, you would need to check for all of them
with(argument3) {
  if(distance_to_object(other) < 5) {
    instance_destroy();
  }
}

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users