How do I kill characters off one by one ?

0 favourites
  • 8 posts
From the Asset Store
120 Epic Fire FX Animations + 2 Bonus Characters. Contains 3000+ frames and a lot of Pixel Art Sprites
  • Say if i want to kill a character, via pressing the key "x"; how to i prevent it from killing all the respawned characters at the same time?

    As in I would like to kill them off one by one!

    Any help is appreciated(:

  • You need a method to refer to that one particular object.

    Either by its UID, or by some instance variable given to them, and then use the "pick" method to pick your object.

  • A simple

    on x pressed

    system pick random character

    destroy character

    would do.

    If you want to specify which character to destroy first, you should create a condition so the computer knows which one you mean.

  • Thanks for the replies guys.

    Yeah, the difficulty i'm facing is creating a condition to so that the computer kills the earliest spawned character.

    I've been trying to figure out the UID and IID. But i'm still stumped. Heh

  • There are probably much easier solutions,

    but workaround for that could be something like this:

    Give the character an instance variable "number"

    character on created

    character set variable "number" = character.count

    character on destroyed

    pick all characters

    (- for each character)

    character set variable "number" - character.number-1

    on x pressed

    system pick by comparison - character.number = 1

    character destroy

  • Yes, there is an easier solution:

    [your triggering event]

    --pick enemy with enemy.iid = 0: destroy

  • Yes, there is an easier solution:

    [your triggering event]

    --pick enemy with enemy.iid = 0: destroy

    You're quite right..

    I knew there was something like that, haha..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • woohoo. thankyou mindfaQ for the tip, it works! and thanks to everyone who replied.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)