Hi! I'm trying to make global animations like "vanishing" or "appearing". So I gave my base character sprite an AnimationPlayer2Dand added the animations. Then created other characters inheriting from the base scene, so each one had the same AnimationPlayer ready to use.

But I discovered AnimationLibrary is a resource, so every change in properties like position, scaleor transparencyin the AnimationPlayer for one scene would reflect in others. I hoped the animations would transfer and I could edit tracks individually.

I discovered I can make the animation "unique", which stops referencing the original AnimationLibrary resource and allows me to modify properties with no effect in other inherited scenes. But then if I want to correct something in the global animations, I would need to do it individually. Either that or export the original resource, load it in every inherited scene and try to transfer all my individual corrections.

That would be a lot of work that may make me think twice before trying new animations. Is there a more efficient way to do this? I need the animation itself to be the same for all scenes, but the tracks' data like "position" to be different for every scene. Thank you beforehand!

  • xyz replied to this.

    Godoten Change the data via script at runtime. This data can also be held in custom resource objects.

      xyz This means creating a resource that holds animation data and add it to every Character, and use it to modify key points in the tracks' timeline for every animation? Then I would need to also make a new system that uses the data to edit the player. Too bad the tracks' keyframes are so dependent on resources... 🙁

      • xyz replied to this.

        Godoten This means creating a resource that holds animation data and add it to every Character

        Of course, but only the minimal data required to alter the animation needs to be stored. How else would you do it? Resources are meant to store data, that's their main purpose.

        A character needs to store this data one way or another. If the animation is the same and the only difference is the value of keys, store those values per character, and then at startup, duplicate the original animation resource and apply the new values to it.

          xyz wait, if resources arrent made to store data, where do i store datas like game state, and maybe score, item parameters like potions and etc etc..??

          • xyz replied to this.

            kuligs2 Where did I say resources aren't meant to store data?

            xyz Resources are meant to store data, that's their main purpose.

            i guess too much coffee for me 😃, my bad

            xyz Yeah, that makes sense. In that case I will go back to using Tween since it seems easier to work with than modifying the AnimationPlayer through code. Thank you!

            • xyz replied to this.

              Godoten You don't modify the player, only the animation resources the player is using.

              Make a function that takes in as arguments the base animation and a custom resource with key value changes, and returns an adjusted copy of the input animation resource. This'll act as a simple parametrized animation system.

                xyz yes you can do this. I will second this method.

                You can also implement a simple state machine that progresses to different animations as the code moves, just with a simple+=1 on whatever variable at the on_Animation_finished(anim_name) signal. You can also use a variable to preload it _on_Animation_started(anim_name) and then use that to read the next animation so there's no stagger between them.