playMaker

Author Topic: How to extend the Max Rows setting on an Array List  (Read 1020 times)

curb47

  • Sr. Member
  • ****
  • Posts: 256
How to extend the Max Rows setting on an Array List
« on: October 26, 2020, 04:01:49 PM »
Hello,

I've got an array set up for my spawned enemies. When the game is not running the inspector shows this:


When the game runs, the component changes to show this (below) where there is now a Max Rows slider, set to 10:


In the game, if it's all kicking off, numerous waves of enemies can spawn, totaling more than 10, here you can see the contents is a 32:


When you shoot/destroy an enemy, it is removed from the array list, and the remaining objects (prefabs) on the list are sent various events depending on other variables. So, the array list is basically a list of 'alive' enemies.

The problem is, if the number of enemies has been quite high, like 32 in this this case; after you have destroyed them all in the game, there are still some left on the array list. Surely, if there are no enemies alive the array should be empty.

This screen grab shows the array list has a content value of 8, but in fact, there were no enemies alive at this time.


Do I need to somehow extend, or +1 at each enemy spawn, to the number of max rows? Or maybe there's something I'm missing?

Thanks in advance for any help.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: How to extend the Max Rows setting on an Array List
« Reply #1 on: October 27, 2020, 03:24:36 AM »
Mmm.... I found this old post that clears up the Max Rows thing, but that leaves me wondering how/why I'm ending up with objects in my array list when it should be empty.

Any ideas?

https://hutonggames.com/playmakerforum/index.php?topic=10418.0


Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: How to extend the Max Rows setting on an Array List
« Reply #2 on: October 27, 2020, 07:49:12 AM »
How do you remove the enemies from the array?
Available for Playmaker work

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to extend the Max Rows setting on an Array List
« Reply #3 on: October 27, 2020, 08:36:43 AM »
Hi.
You will need to check your fsm setup.

Where/when are you removing the objects from the list.

a wrong reference could cause not to be removing from the list for example.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: How to extend the Max Rows setting on an Array List
« Reply #4 on: October 27, 2020, 04:06:58 PM »
Hi there,
I'm removing them from the array list using:



I think I can see what's going wrong...


Pool Boss is set to Recycle Oldest, but if the oldest is still alive, maybe it's adding an additional item to the array list, but not actually respawning anything because the 'oldest' is still alive?

If there are 10 Enemy2 prefabs already spawned from the pool, if none of them are dead, what does Pool Boss do when it's told to spawn another Enemy2?

Maybe I should just use Allow Instantiate More and set the level to be really high?
 

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to extend the Max Rows setting on an Array List
« Reply #5 on: October 28, 2020, 03:20:56 AM »
Hi.
Something you can try is, before you add to the list.
check if it exists in the list.
and if exist don't add again, or remove 1st and then add again.

Then oldest can be respawned without 'Dead' event happening (aka not removing from list).

Setting a large amount will increase loading time as the pool will create them on start.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: How to extend the Max Rows setting on an Array List
« Reply #6 on: October 28, 2020, 09:57:00 AM »
Great stuff! Thanks Djaydino, that all makes sense.