Hi I am in thinking about pooling monsters…
For example I want to have 20 bats, 10 snails on the scene.
I know that there is no way that player will see more then 3 monsters at once (with same type like snail)
So I would like to have a pooling system for monsters:
I would only instantate 3 bats and 3 snails.
When player comes close to the monster I detect it OnTriggerEnetr2D and simply pool an monster.
That’s sounds good, but with my knowledge I would need to create an global MonsterPoolManager where I would have to makre GameObject Bats, GameObject Snails etc… I would also need to have seperate counter(pointer to index) for each of them. What becomes silly if I would have about 30 types of monsters in whole game…
I was thinking about puting all Monsters in one array and just pool them by searching in the loop by id or name, but that wouldnt be a very efficient way right? I mean if there was about 10 placeholders for monsters it would mean that I have to do the loop through all monsters array ten times… I guess it could cause lags…
What would be a shortcut for that? I feel that I don’t know something important, or I didnt come up with a proper idea…
Thanks in advance!