How to make something happen when all actors of a certain group [SOLVED]

ConquistadorBob

  • Posts: 21
You know The Binding of Isaac It's kind of like that. Where when you enter a room, you need to kill everything in that room before the doors open.  I really don't know how to start doing this. There are multiple different enemy actors in each room, but they all have the group enemy. How would I go about making a door open when all actors of enemy are dead?

« Last Edit: May 26, 2020, 08:43:35 pm by ConquistadorBob »

Luyren

  • *
  • Posts: 2783
Code: [Select]
Scene Behavior
Number of Enemies: hidden number attribute.
Enemy Group: non-hidden actor group attribute.
Updating
-Set Number of Enemies to 0
----for each actor in group [Enemy Group]
----increment Number of Enemies by 1
-If Number of Enemies = 0
--All enemies have been defeated, do whatever you want here.
You can also make that an actor behavior, if you want to do something to that actor when all enemies are defeated.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.


ConquistadorBob

  • Posts: 21
Code: [Select]
Scene Behavior
Number of Enemies: hidden number attribute.
Enemy Group: non-hidden actor group attribute.
Updating
-Set Number of Enemies to 0
----for each actor in group [Enemy Group]
[quote author=Luyren link=topic=60560.msg313855#msg313855 date=1590538272]
[code]
Scene Behavior
Number of Enemies: hidden number attribute.
Enemy Group: non-hidden actor group attribute.
Updating
-Set Number of Enemies to 0
----for each actor in group [Enemy Group]
----increment Number of Enemies by 1
-If Number of Enemies = 0
--All enemies have been defeated, do whatever you want here.
You can also make that an actor behavior, if you want to do something to that actor when all enemies are defeated.
Thanks! I only thought have having a separate behavior for each scene where I manually set a number that goes down when each enemy actor dies. I didn't know how to count the enemy actors automatically. Tysm.