Ive redone the animations multiple times, and now its gonna be another one.. Im tired of this.. There has to be a better way to set up nodes such as you can reuse the same animations.

The problem: When im creating animation in godot, it is tied to the node that i select, either the parent node (WeaponSlot) of a weapon where i manipulate position and rotation or the weapon scene (Weapon) itself. If it is the WeaponSlot then i have to add and animate all types on the slot, but maybe a weapon has some unique animation like a flick or something that i wan to add, then that means i have to keep the animation on the weapon scene.

The idea is to have few weapon types:
Sword
Spear
Projectile

Sword = swing
Spear = stab
Projectile = throw.

I want multiples of the same type weapons, like multiple swords, multiple spears etc.. Thus i want to reuse the animations.

Following composition convention, im thinking i could make the animation player or maybe i need animation tree as component? But then how do i animate a node that is a generic node and then later reference it on the exported value?

Right now my weapon contains information about damage it does as a Weapon class instance, along with hitboxcomponent.

Maybe someone of you has already had this problem and has a better way to set the nodes up?

    kuligs2 I'm working on a project like this so I can't speak to whether my method will work with your game architecture. But I am using an "attack area" for my player and having the damage/animation handled by state machines. If you use StateAnimationTree nodes in the animation tree, you can set an "advance" condition or just use a match pattern to travel() to the right animation. Then you make sure you link each animation back to your "idle" animation and auto advance when the attack ends. I am using a state machine with a simple number to determine which weapon graphic currently displays.

      kuligs2 Animations are resources. You can save/load them.

        @kuligs2
        If WeaponSlot is a node to hold the weapon then you'd just animate WeaponSlot based on weapon type once then just place the weapon there? Am I missing something.
        Or are you saying the WeaponSlot animation is different for each sword (eg. sword01 = swing01, sword02 = swing02..etc)?

        xyz yes i can export the animation as resource but getting it back to apply to a different "node" did not work, thats why im asking.. Lets say i animate the node Sword

        I select the blue one.
        Then i add the properties - position/rotation.
        I animate. All good.

        Then export:

        Now i have resource

        Now i create Spear as an example and apply the same animation.

        Well..

        Case closed i guess..

        I swear, yesterday i did exactly this and it was trowing me warning and i went on goose chase debugging but all in vein.. Jeeesless christ..

        This was named Sword from the original animation, and when i imported/loaded it into spear it was still Sword and was telling me it cant find the node, which is obvious, because its spear..

        Now the question is how do i export the animation resource to a varriable so that i could assign it to animation player via code?

        • xyz replied to this.

          SnapCracklins I have played with statemachines and animations like character walking-running transitions, i understand that, but what im working on is a simplified version of an attack animation for different types of weapons. Weapons of different skins that share the same animation.

          The idea here is to understand how to architect this method of applying/animating animations so that i could scale it up to larger sets of objects. So that i dont end up with hundreds of assets with each unique animation... that would be out of my budget atm 😃..

          All of this is just a hobby, no money involved, just something to keep my brain active and not do some other degeneracy with my free time. 🙂

            kuligs2 oh i see! Then you should be able to just load skins/textures with your weapons. Just change the texture at your weapon change.

            Another day another bullshit.

            Look i told you, it does not work.

            Man i hate this, that one day it works another day you do the same steps and it doesnt.

            This inconsistency is python like, thats why i hate python.
            You saw yesterday i exported this animation and added to spear. Now i wanted to try to add them to sword, and i cant...

            This lead me to believe that the saved resource wasnt saved at all.. the thing i save was a pre-resouce, meaning that its a file that has the references to built in resource that are inside some other scenes...

            If i save the Animation lib:

            It says Stabber.res, but the animations are not saved... it says built in.
            Now i save them all:

            Check the spear from yesterday.

            Yeah the animations were not saved.

            Compare to screenshot form yesterday:

            It says built in.
            IMO this is bull... when you save the whole library it should grab all the animations with it and save them to disk as resource.. It makes no sense to save a reference to the built in resource... unless.. You have a dummy scene with a dummy. You animate the dummy, and then save the LIB as resource to use it elsewhere.. jeesless christ.. And if you delete the dummy, you loose it all..

            After adding the Stabber LIB to Spear, you can see it says.res next to the animations.

            And now deleting the AnimationPlayer from Sword, and readding the Stab LIB finally works.. Animations are saved..

            This is a newb pitfall... i hope someone besides me learned somehting here.

            P.S.

            Also what is the difference between adding property track VS 3D position track? Isnt that the same property?

            It looks different on the timeline

            kuligs2 You can write a small tool script for transferring animations. Simply iterate through animation's tracks and assign different node path(s) to them. Look the reference for Animation resource class.

              xyz But is there a way to have lets say a class or resource script where i can add the saved animation library via exported varriables?

              I looked through the docs but could not find how to import/set the animation library for animation player via script.

              • xyz replied to this.

                kuligs2 AnimationPlayer inhertis AnimationMixer which has methods to get/set used animation and animation library resources.