Preloading animations via lua script & the meaning of ActiveAnimations

  • #1, z F_KalMonday, 10. April 2017, 23:02 hodinky 8 years ago
    From what I read in posts dating back to 2015, preloading/unloading animations was being reworked at the time. I'm running version 4.2.5 and it seems to be working good though.

    a) Using actionparts to preload an animation during scene loading is straightforward enough and works wonders! But how would you achieve the same effect in lua? I haven't managed to get the following syntax working - maybe I have it wrong?
    ActiveAnimations["animName"].AnimationPreloaded=true
    b) I'm not even sure what the table ActiveAnimations contains... Is it al the animations that are currently playing? What about those that have started and then stopped?

    c) Is there some way to preload an animation that doesn't have a unique name?
    Perhaps using its full path - for instance something like: 
    Scenes["sceneName"].SceneObjects["objectName"].ObjectAnimations["animationName"].AnimationPreloaded=true
    Thanks!

    Fanoušek fóra

    107 Posts


  • #2, z afrlmeMonday, 10. April 2017, 23:33 hodinky 8 years ago
    The ActiveAnimations table contains currently playing animations & animations that have already been preloaded. All other animations are in the regular Animations table.

    You can't preload animations with Lua script that aren't already currently playing. I guess if you were to start an animation then set AnimationPreloaded to true that it would keep it in memory until you manually unload it from memory.

    I really don't recommend preloading unless you have to. Instead use webp image files & various other tricks to keep the file-size & animation frame count down. Better optimization means they will run better on potato machines without needing to preload - they already load frame by frame, so the smaller the file size per frame the faster they will load.

    P.S: if you do want to use the preloaded animation system then don't forget to manually unload animations when you know longer need them as they will over time fill up the cache/use up vram & cause your game to run slow/sluggish.

    Imperátor

    7285 Posts

  • #3, z F_KalTuesday, 11. April 2017, 14:58 hodinky 8 years ago
    Thank you @AFRLme for the explanation! Eventually I'll be using the webp format but in this case I'm trying to synchronize mutliple animations appearing on screen in "parallel" so preloading is very tempting :-)
    You can't preload animations with Lua script that aren't already currently playing. 
    Just to make sure I understand you correctly, you are saying that,  no matter what you do, you cannot preload any animation with some lua call since the animation has to be already loaded - correct? Seems to be my conclusion aswell, but such a pity.

    Fanoušek fóra

    107 Posts

  • #4, z afrlmeTuesday, 11. April 2017, 15:05 hodinky 8 years ago
    Aye, AnimationPreloaded only seems to be a field available in the ActiveAnimations table. You could unload a preloaded animation listed inside of the ActiveAnimation table with Lua script though I guess.

    Imperátor

    7285 Posts

  • #5, z F_KalTuesday, 11. April 2017, 17:06 hodinky 8 years ago
    Thanks @AFRLme, that makes sense!

    Fanoušek fóra

    107 Posts