0 Favourites

How to keep an enemy count right?

  • Hi there,

    I'm trying to count how many enemies are, for example, inside a jail, in a particular zone.

    The problem I have is that when several enemies enter that zone at the same time, only one of them is counted by the program. I have this logic right now:

    If enemy is overlapping jail sensor (covering all the floor) TRIGGER ONCE ==== add 1 to jailenemycount (global variable).

    That didn't work, so I tried:

    If enemy is overlapping jail sensor and enemy's instance variable "countthisone" = 0 ====== set countthisone to 1

    and then, when enemy's countthisone = 1 ====== add 1 to jailenemycount and set countthisone to 0

    I'm missing something here. Any help will be very welcome.

    Thank you in advance!

  • try this demo

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Hi Lordshiva. Thanks, but there's a problem. The real situation is that I have an area where enemies can enter and others can spawn. So, there's no collision when an enemy spawns inside directly. Instead, I should use (I think) overlapping, but doesn't seem to work. I don't know if it's a program's limitation or something.

    EDIT: I restarted the program and now collision works when spawning. I don't know why. Thank you very much and sorry =)

  • sirkame it's okey no need to say sorry. We are here to help one another

  • It would not be inappropriate to use a loop when you wanted to count up the enemies- "For Each Enemy" combined with "Enemy Overlapping Jail"

    I've made you an example that uses this, and therefore even keeps track of enemies that leave the jail.

    New enemies pop up every once in a while, and the more there are, the slower new ones appear.

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