playMaker

Author Topic: Spawn a specific number of enemies [SOLVED]  (Read 4449 times)

Thyriax

  • Playmaker Newbie
  • *
  • Posts: 25
    • Torii games
Spawn a specific number of enemies [SOLVED]
« on: November 05, 2013, 10:01:20 AM »
Hello there !
I'm working on an old 8bits classic games using Playmaker and i'm stuck with spawning enemies.
I have to build a wave of 15 enemies, spawning by 3 empty gameObject.
There can be only 3 enemies on screen only.
I've already build the countdown of enemies with an IntCompare but i would like to spawn a new enemy each time an enemy was killed (in my case, they're disable, not destroyed).
At this time, i've several problem to build the correct FSM.
I've put Prefab(enemy) on a Global Variable and store it on a "Create Object" action. The integer (number of enemies) was store in a Global Variable too.

How can i solve this problem ?
Thanks for help! :)
« Last Edit: November 06, 2013, 06:26:31 PM by Thyriax »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn a specific number of enemies
« Reply #1 on: November 05, 2013, 10:10:04 AM »
There's a couple ways to do this..

On your enemy, tell it when it spawns to increase a global variable (totalEnemies), then in the enemy spawner fsm have it compare the totalEnemies amount and if it is less than 3 then send the event to spawn a new enemy. When an enemy dies have it reduce the total enemy number. This should work okay, you may have speed glitches and need to utilize Next Frame Event on the spawner to avoid it running faster than the enemies can spawn and change the total number.

Or, spawn them and immediately parent them to another empty object, then use Get Child Count on the parent and compare the amount to send a spawn event if it is too low. I like this much better.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Thyriax

  • Playmaker Newbie
  • *
  • Posts: 25
    • Torii games
Re: Spawn a specific number of enemies
« Reply #2 on: November 05, 2013, 10:41:52 AM »
Thanks to reply Lane.

Well, as a newbie using PlayMaker, i'll try make this possible !

Quote
Or, spawn them and immediately parent them to another empty object, then use Get Child Count on the parent and compare the amount to send a spawn event if it is too low. I like this much better.
no problem of frame rate or DrawCalls with this method?

Thanks!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn a specific number of enemies
« Reply #3 on: November 05, 2013, 10:55:11 AM »
I doubt there would be any issues with drawcalls... You can hit the Stats button in the game view to compare before/after. You could do a bit of both to signal the compare instead of doing it every frame if necessary.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Thyriax

  • Playmaker Newbie
  • *
  • Posts: 25
    • Torii games
Re: Spawn a specific number of enemies
« Reply #4 on: November 06, 2013, 11:05:55 AM »
hhmmm... I'm still stuck on this problem.
I've mofidied spawning FSM but it's doesn't work.
If i want to spawn an enemy after killing one, FSM spawning 3 more enemies because of the 3 spawn point (so 5 enemies on screen).
If i disable the "every frame" option on Int Compare (to spawn only 3 enemies per wave), it's doesn't spawning enemies at all. I must do it manually (with alt key).

Should i split the "Create Object" action in 3 different states for each spawing point?

Thank for answer !

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn a specific number of enemies
« Reply #5 on: November 06, 2013, 12:20:14 PM »
Here's an example.

Click to destroy the spheres. The spawner will maintain 3 spheres for its lane.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Thyriax

  • Playmaker Newbie
  • *
  • Posts: 25
    • Torii games
Re: Spawn a specific number of enemies
« Reply #6 on: November 06, 2013, 05:19:41 PM »
Thanks a lot Lane.
I'll try to understand from your example and reply if it's working on my scene.

Thyriax

  • Playmaker Newbie
  • *
  • Posts: 25
    • Torii games
Re: Spawn a specific number of enemies
« Reply #7 on: November 06, 2013, 06:26:04 PM »
Great News !!!
Many Many Thanks Lane !!!
Those 3 examples are really great and easy to understand!
I've use one of them and apply to my scene with a countdown of 15 enemies !!
All Working good !!

Thanks again Lane for your help and your time!