How do I optimize resource usage with instanced animations?

0 favourites
  • 4 posts
From the Asset Store
Mine those precious space resources & start trading
  • I have one animation for a burning tree. In the first frames it is perfectly healthy, then begins to burn and finally burns down to cinders.

    My forest can catch fire. The fire propagates to other trees, destroying large sections of the forest in the end.

    Can using instanced sprite animations of just one "burning-tree" animation spare resources in this case? Can I conserve memory and CPU cycles by using only one "burning-tree" animation and starting instances of this one animation at different game-times and screen-coordinates - as the fire propagates?

    Eventually I want XCOM-1-style large-scale fires. Does instancing help here conserving memory and some CPU resources? The whole forest fire is just one sprite animation put on the screen at many coordinates at once, playing with different start times. I want to make the instances begin at random times so the burning tree animations on screen will NOT be synchronized.

    Can instancing or an other solution preserve resources in this case? Memory, CPU cycles?

    Does instancing makes sense in this case?

    In 3D rendering, engines can use instanced geometry objects - reserving memory only for one object - and rendering many of its instances.

  • I am not very sure if I understand your problem, but I'll try to clear something out.

    If your forest is made with one tree, then you can use one sprite for everything. You can create a default animation as let's say "idle", and second animation of the same sprite for burning. Now it would be obviously resource saving to make forest by creating multiple instance of the same tree instead of using many different objects.

    If you have many different kind of trees then you might consider creating a separate sprite to imitate the fire which you could spawn on the particular trees. In such case you don't have to put butning animation in each tree sprite which will save some memory for sure.

    Anyway many objects/instances will cause performance drop - that's normal, so this is the first thing you should consider for optimisation. Next thing is the "weight" of the images you use for those sprites/animations. The rule is pretty simple, the more objects and sprite animation frames you have in your game the more memory and CPU resources it will take to load it up.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So then if any more than 1 animated sprite is displayed on screen, playing the frames looped, the second sprite will always be an added resource hog, no matter if it's an "instance" of the first sprite or a completely new sprite.

    More sprites linearly increase CPU and RAM usage then, I guess.

  • Second instance of the same object will also take some RAM memory because game engine generates an object (from the programming term) which needs a possibility to be treated separately in any way. The same goes for animations. Every animation on your screen (no matter if it's an instance of the same object or not) eats some CPU resources because it has to be rendered on the screen separately (it might start burning later or earlier right?).

    Now what they have in common (all instances of the same sprite) is the sprite object. Which is simply a - let's say - starting template for the instances. So when you use many different sprites/trees then your game will have to store many "templates" which will use some more memory.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)