Recycling actor pools? Advice...
Threepwood
Member Posts: 30
I get the concept that spawning in gameplay is bad. I understand that you want to do something like place 10 bad guys off screen at the start of a level and move them in from the pool as needed, and when killed, you just move them back offscreen to await rebirth.
What I don't really know how to do in GS is track the actors in the pool and know how to bring a specific one back. With a normal language you'd just have an array or something.
It's pretty easy to use a counter to know how may are on screen vs off, so you know if the pool has a free resource for a 'spawn'.
Do you use the tag system or something like that to indicate if an actor is available?
What I don't really know how to do in GS is track the actors in the pool and know how to bring a specific one back. With a normal language you'd just have an array or something.
It's pretty easy to use a counter to know how may are on screen vs off, so you know if the pool has a free resource for a 'spawn'.
Do you use the tag system or something like that to indicate if an actor is available?
Comments
Say you are shooting bullets and can have maybe 3 on screen at a time (before they hit the edges and disappear and get reallocated). How do you go about cycling through the 3 shot pool in the best way, knowing which bullet actor is free off screen?
refer to http://gamesalad.com/forums/topic.php?id=9710
search for VictorKin11's demo on recycle bullets on shared projects. he recycles 5 bullets over and over again.
Even with the work I think I'd like to get to a virtually spawn free game. For an example I had 7 characters walking around, the player and shooting invisible, fast moving projectiles (bullets), and spawning blood particles when hit.
The game started and stayed at 60fps for a couple of mins. I was tracking the spawns and destroys on screen and once you got over about 300, you'd start getting fps dips to 40 or lower. Dropping from 60fps to 40fps is not ok. Feels terrible and will never fly on older phones. Has to be memory fragmentation or something? It will be a day or work but it should be pretty trivial to reduce virtually 100% of the spawns and have it just load up on level init and then the fps *should* stay at 60.
For any game that needs to spawn > 100 actors per scene you'll probably have a better game using recycled pools. Once you put a counter on screen you will be shocked how quickly you can approach 1000 spawn/destroys.
Does it leak memory or is it a performance concern?