Counting the number of overlapping sprites (SOLVED)

Get help using Construct 2

Post » Mon Sep 19, 2016 2:23 pm

In my game I have small bee enemies that attack the player in groups. I want them to do x amounts of damage per second per bee, but no matter the amount of bees overlapping the player it only accounts for the damage of one bee, not 10 for example. Is there a way to count the number of sprites overlapping another sprite so I can just multiply the damage of one bee by the total number of overlapping bees. Or is there a way for every bee to do individual damage on the player? All I have tried is; (bee) overlapping (enemy), every (1) seconds -> (enemy) subtract (x damage) from ( health). I don't get why this doesn't work, but I haven't tried much. Thanks to anyone who can help.
Last edited by currypuff on Mon Sep 19, 2016 11:36 pm, edited 1 time in total.
B
14
S
3
Posts: 55
Reputation: 912

Post » Mon Sep 19, 2016 2:37 pm

You could use For each enemy, or use enemy.Count to answer you question directly.
Correction: should be PickedCount, as 99Instances2Go points out.
Last edited by blackhornet on Mon Sep 19, 2016 4:49 pm, edited 1 time in total.
ImageImageImage
B
71
S
22
G
248
Posts: 3,761
Reputation: 138,073

Post » Mon Sep 19, 2016 4:34 pm

every (1) seconds
(bee) overlapping (enemy)
(enemy) subtract (x damage * bee..PickedCount) from ( enemy.health)

health must be a instance variable
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Sep 19, 2016 11:34 pm

Thanks guys, it work perfectly.
B
14
S
3
Posts: 55
Reputation: 912


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests