I am looking into way how to efficiently handle cases where I need to have composite sprites for enemy characters, and I would if someone could give me a lead towards good solution.
What I want to accomplish? Let’s say I have game that spawns hordes of enemies let’s say 30 basic types with a lots of accessories like weapons, armor… this happens randomly so there may be a lot of enemies of one type and others may not be spawned at all
Solutions I have but don’t like.
When it is decided instantiate whole hierarchy of sprites which can seriously impact game’s overall performance… don’t like this solution at all
Better solution - have every component in object pool and then assemble these objects when being spawned. This could require possibly several hundreds of pools for components that have only visual effect on game, which I’ don’t like very much, but still much better option than the first one, in my opinion.
What would I ideally like to accomplish:
Have an GameObject with an Enemy component attached to it without graphics. This component would have non MonoBehavior composite object SpriteComposite who has reference to a Sprite and a List of children Sprite composites, game then renders sprites on coordinates that are stored in these objects thus creating final effect.
Thank you for any suggestion.