How to keep an enemy count right?

Get help using Construct 2

Post » Thu Feb 05, 2015 8:38 am

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!
B
5
S
1
Posts: 32
Reputation: 508

Post » Thu Feb 05, 2015 9:04 am

try this demo
You do not have the required permissions to view the files attached to this post.
B
226
S
31
G
14
Posts: 1,899
Reputation: 38,273

Post » Thu Feb 05, 2015 9:35 am

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 =)
B
5
S
1
Posts: 32
Reputation: 508

Post » Thu Feb 05, 2015 11:01 am

sirkame it's okey no need to say sorry. We are here to help one another
B
226
S
31
G
14
Posts: 1,899
Reputation: 38,273

Post » Thu Feb 05, 2015 11:33 am

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.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236


Return to How do I....?

Who is online

Users browsing this forum: Brawlitup99 and 10 guests