Animations do not play if called after a pre-load

  • #1, by bananeisafreeMonday, 02. January 2017, 19:08 7 years ago
    Hi.
    This is a strange one.
    To smooth the game i'm making, I made an action "called at the beggining of the scene" to preload all the scene animations.
    Thing is. Once this is done, the animations do not show.
    If I call the same animations without preloading them it works just fine...

    I must confess I'm a bit puzzled there... I thought I had VS figured out by now ! :p

    Am I doing something stupid ?

    Forum Fan

    120 Posts


  • #2, by afrlmeMonday, 02. January 2017, 19:59 7 years ago
    The idea is to preload them before showing a scene. I however don't recommend using preloading unless you really need to.

    By default the engine since 4.x loads animations frame by frame which is faster than the old method of loading an entire animation before playing it. Preloading is essentially same as the old loading method except preloaded animations once loaded into memory will stay in a cache until you manually unload them (not necessarily a good thing; especially if you forget to unload them after you no longer need them as they will eventually cause your game to start slowing down over time). Regular animations end up in a temp cache & get removed over time as new animations are added to the temp cache.

    Personally seeing as you are working on a low res -ish pixelart game, I wouldn't bother with preloading animations. Instead use some of the other optimization methods such as using webp format instead of using your original png files & try not to use 5 million frames or duplicated frames. Also seeing as it's pixelart, there's no reason animations have to be super sharp or in focus, so you could - let's say for your environmental animations - create them at say 50% of the intended size you want to display them in your game at & then inside of the first frame, include an execute a script with something along the lines of this...
    ActiveAnimations["ufo"].AnimationSize = 200 -- scale animation "ufo" to 200%

    Anyway, webp & scaling & lack of frame duplication & not to mention the low-ish resolution should ensure your game will run smoothly on even the most basic of potato rigs. wink

    Imperator

    7278 Posts

  • #3, by brut69Monday, 02. January 2017, 22:03 7 years ago
    I have a similar problem where I preload a couple of characters as soon as the game starts and when those characters appear , the game "lags" until it loads them ... so basically it acts like the pre-loading doesn't work.
    Any way to make sure a character preloads?

    Great Poster

    266 Posts

  • #4, by afrlmeMonday, 02. January 2017, 22:29 7 years ago
    I have a similar problem where I preload a couple of characters as soon as the game starts and when those characters appear , the game "lags" until it loads them ... so basically it acts like the pre-loading doesn't work.
    Any way to make sure a character preloads?
    Maybe load them at game launch?

    Imperator

    7278 Posts

  • #5, by bananeisafreeTuesday, 03. January 2017, 12:34 7 years ago
    @AFRLme

    Well even though our game is in a pixelized state, we do actually fool around with high resolutions so that we can put more details on far away objects than what a low res setting would offer.
    As such, our end result is in 1920x1080. And at that res, even with webp conversion, when numerous animations start at the same time, we got a few seconds of low framerates at the beggining of each scenes.

    For the TechDemo I remember using the preload trick for some of the heavier animations, and it did the job quite well. But curiously here, preloading the animations just prevent them from happening alltogether... I was wondering if it was a bug or if I justed goofed.

    @Brut69. From what I understood, "at the start of the scene" does not exectute before everything else. But does once everything is "set". That is why you can't use a "preload animation" action for animations that are used as default animation for an object. The game will play the animation before reading the "at the start of the scene". So as Lee stated, preloading your characters at gamelaunch with the " At begin start following action" in the game properties tab should do the trick.

    Thank you for your awnsers !

    edit : @AFRLme I'm gonna fiddle around with manualy increasing each animations size and get back to you wink.

    Forum Fan

    120 Posts

  • #6, by afrlmeTuesday, 03. January 2017, 13:24 7 years ago
    For the TechDemo I remember using the preload trick for some of the heavier animations, and it did the job quite well. But curiously here, preloading the animations just prevent them from happening alltogether... I was wondering if it was a bug or if I justed goofed.
    Preloading doesn't mean they will start as soon as they are done preloading. They just stored permanently into the cache until you manually unload them. To have them play you still need to manually play them or assign a default animation to a scene object via its properties tab. I guess preloading at the beginning of a scene won't work with animations that are supposed to start automatically because you are causing a conflict query between preloading & start animation... a theory at least - I've not had cause to bother using the preload feature.

    Just remember that game development, design & optimization is all about compromise. By this I mean what you have in mind might be unrealistic in terms of the pc spec target you are aiming for, thus you may need to remove or edit certain things to get your game to play smoothly. As I mentioned in the optimization wiki article I wrote a while back: "Game development is more akin to directing a movie, than writing a novel, in that unlike writing a novel, we are limited to time, money, resources, space & what your target spec machine can handle. It's all good & well having $10k plus custom built super computer & basing how the game works on that, but If you stumble across any issues on your machine, then it's unlikely it will work nearly as well on entry to mid level gaming laptops or computers. Food for thought."

    @Brut69. From what I understood, "at the start of the scene" does not exectute before everything else. But does once everything is "set". That is why you can't use a "preload animation" action for animations that are used as default animation for an object. The game will play the animation before reading the "at the start of the scene". So as Lee stated, preloading your characters at gamelaunch with the " At begin start following action" in the game properties tab should do the trick.


    Actually some actions will run instantly inside of an at begin of scene action when you load a scene, it's just some of them require the scene to load first, such as autosave, which is why it's often recommended you add a pause for say 500ms to 1000ms or so - anything over 1000ms is probably the safer bet.

    Imperator

    7278 Posts

  • #7, by afrlmeTuesday, 03. January 2017, 13:24 7 years ago
    For the TechDemo I remember using the preload trick for some of the heavier animations, and it did the job quite well. But curiously here, preloading the animations just prevent them from happening alltogether... I was wondering if it was a bug or if I justed goofed.
    Preloading doesn't mean they will start as soon as they are done preloading. They just stored permanently into the cache until you manually unload them. To have them play you still need to manually play them or assign a default animation to a scene object via its properties tab. I guess preloading at the beginning of a scene won't work with animations that are supposed to start automatically because you are causing a conflict query between preloading & start animation... a theory at least - I've not had cause to bother using the preload feature.

    Just remember that game development, design & optimization is all about compromise. By this I mean what you have in mind might be unrealistic in terms of the pc spec target you are aiming for, thus you may need to remove or edit certain things to get your game to play smoothly. As I mentioned in the optimization wiki article I wrote a while back: "Game development is more akin to directing a movie, than writing a novel, in that unlike writing a novel, we are limited to time, money, resources, space & what your target spec machine can handle. It's all good & well having $10k plus custom built super computer & basing how the game works on that, but If you stumble across any issues on your machine, then it's unlikely it will work nearly as well on entry to mid level gaming laptops or computers. Food for thought."

    @Brut69. From what I understood, "at the start of the scene" does not exectute before everything else. But does once everything is "set". That is why you can't use a "preload animation" action for animations that are used as default animation for an object. The game will play the animation before reading the "at the start of the scene". So as Lee stated, preloading your characters at gamelaunch with the " At begin start following action" in the game properties tab should do the trick.


    Actually some actions will run instantly inside of an at begin of scene action when you load a scene, it's just some of them require the scene to load first, such as autosave, which is why it's often recommended you add a pause for say 500ms to 1000ms or so - anything over 1000ms is probably the safer bet.

    Imperator

    7278 Posts

  • #8, by bananeisafreeTuesday, 03. January 2017, 14:02 7 years ago
    Preloading doesn't mean they will start as soon as they are done preloading

    Oh I am well aware of that ! smile
    No the issue is that when I call an animation (via the "play animation" action part) . If I've preloaded said animation before (at the begginning of the scene or otherwise), the animation wont show. The action on each frame (changing a value or a condition at a certain frame for exemple) will apply though, at the correct pacing. It's just that there is no visual at all !

    I tottaly agree on the compromise subject, that is why I do my best to optimise as much as I can while still trying to offer my artist the best canevas possible to express herself.
    And I've been following numerous of your advices in that matter :p .

    Thanks again for taking the time to awnser.

    Forum Fan

    120 Posts

  • #9, by afrlmeTuesday, 03. January 2017, 14:27 7 years ago
    Hmm, strange. Sounds like a bug to me. Anything mentioned in the messages log file after trying to play the animation?

    Imperator

    7278 Posts

  • #10, by bananeisafreeTuesday, 03. January 2017, 15:37 7 years ago
    Nothing related to that no.
    I added several "print x,y,z" scripts after each preload to see if it rand trough the whole action and it did. But still, no animation showed for the one that were preloaded.

    I used the reduced size trick. It helped quite a lot. Especially on smaller rig ( I use a asus T100 as a test machine for low end pc).

    I would love to be able to preload some of the animation though. (long ones with pause between each frame that would reduce the game FPS a tad at the start of a scene) 

    Forum Fan

    120 Posts

  • #11, by brut69Tuesday, 03. January 2017, 16:42 7 years ago
    I have a similar problem where I preload a couple of characters as soon as the game starts and when those characters appear , the game "lags" until it loads them ... so basically it acts like the pre-loading doesn't work.
    Any way to make sure a character preloads?
    Maybe load them at game launch?

    But that's what I am doing... "I preload a couple of characters as soon as the game starts" and when those characters appear a few scenes afterwards (like 10 minutes into the game) the game lags until they are loaded

    Great Poster

    266 Posts