PlayMaker News > General Discussion

CG.Alloc in prefabs containing FSMs instantiated at runtime

(1/2) > >>

toddprofanegames:
Hello,

I am heavily using PlayMaker throughout my game (currently running v1.9.7), which is a large seamless world with no loading screens.  All enemies have about 4 to 5 FSMs with many actions on them which handle their behavior.  When the player walks over certain triggers, enemy instances are created and loaded into the world.  After much optimization of my custom code, I'm finding the primary and most significant remaining bottleneck is all the heap allocations that occur in the scope of PlayMakerFSM.Awake. 

I've attached a screen shot of the profiler.  I'm just wondering if there are any plans to somehow make FSMs less dependent on heap-memory, although without knowing the internal workings of the code I can't really begin to guess what can be done to address this. 

For the record, I can't just pool these enemies at startup, as the game is far too large to let all that data sit in memory as disabled GameObject instances for the life of the application.

Broken Stylus:
A game with far too many enemies to be pooled?
It looks like you're doing a game that has you shoot a ton of them, or maybe fighting against a whole horde with some crazy nodal pathfinding.
I'm not sure why these objects (enemies) take up so much resources.

jeanfabre:
Hi,

You should not instantiate all your ennemies in a pool, instead you should ballpark how many ennemies can be seen and active at a time and that becomes your pool size.

then you take from the pool and if one more enemy is needed, then the pool will instantiate a new one and increase by one the pool count.

that's how you do it, you NEVER instantiate all your ennemies in one pool, that's now the purpose of a pool.

Does that make sense?

so, yeah, definitely use a pool, if you need more help on this, I can give you guidance.

Bye,

Jean

Broken Stylus:
The developer must define what is the optimal maximum amount of enemies present at a given time which the player can interact with, and then recycle them. It's possible that toddprofanegames makes a game that may be some kind of top down shoot'em up with tons of enemies at a single moment, and that is simply too much to handle for his machine.

jeanfabre:
Hi,

ALL regular c# top down shooters uses pool, this is the only way to be really efficient, else you need to go ECS...

on screen at a given time, there are only so much that can be shown really. "Tons" is a very subjective amount :) check screenshots of the most crowed level of typical TDS and you'll see that you are within the 100's, not the thousands, even with bullets.

 don't hesitate to put some stats on how much visible ennemies of each type is visible, keep track of it as you play and QA your game and increase the pool count as required.

Bye,

Jean

Navigation

[0] Message Index

[#] Next page

Go to full version