playMaker

Author Topic: How to restart a level after all enemies are gone?  (Read 3415 times)

miczec

  • Playmaker Newbie
  • *
  • Posts: 7
How to restart a level after all enemies are gone?
« on: January 26, 2015, 11:11:41 AM »
Hey there,

I'm working on a simple game, where your only objective is to shoot some enemies. What I'm trying to accomplish is a way to restart the level after all enemies are dead. I tried using "Game Object Is Null", which works perfectly fine if you only have one enemy in the scene. In my case, there are several bad guys to kill... So I asked myself if it is possible to tell playmaker to look if there are any gameobjects tagged as enemy - and if there's no one left, to just restart the level.

Would be great if anyone has a solution.

Thanks,
Mike.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to restart a level after all enemies are gone?
« Reply #1 on: January 26, 2015, 11:12:52 AM »
If you know the number of enemies that are spawned then you can just subtract 1 from that total every time an enemy dies and when the number reaches zero then all of the enemies are dead and you can end the level.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

miczec

  • Playmaker Newbie
  • *
  • Posts: 7
Re: How to restart a level after all enemies are gone?
« Reply #2 on: January 26, 2015, 11:19:40 AM »
If you know the number of enemies that are spawned then you can just subtract 1 from that total every time an enemy dies and when the number reaches zero then all of the enemies are dead and you can end the level.

hey lane, thank you!

i'm kind of stuck in my thinking process right now. so currently, i've set up a empty game object with the following fsm:

State 1: Game object is Null
State 2: Restart Level

so how exactly could i add the subtraction part to this?

sorry, i'm still very new to all this...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to restart a level after all enemies are gone?
« Reply #3 on: January 26, 2015, 11:28:39 AM »
Use a global variable with the total count of the enemies in the level. If you spawn an enemy then add 1 to that count. If an enemy dies, subtract 1 from that number...

This is maintaining a number of the current amount of enemies in the level. Now all you have to do is an Int Compare to 0 and fire and event to a state which ends the level.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

miczec

  • Playmaker Newbie
  • *
  • Posts: 7
Re: How to restart a level after all enemies are gone?
« Reply #4 on: January 26, 2015, 12:08:12 PM »
thanks!

your advice pushed me in the right direction! i found the best solution is to use the "get tag count" action and simply compare it to 0.