Is there a way to discard instancing from code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Aaron M
:warning: Old Version Published before Godot 3 was released.

I have an instanced node that’s used by multiple creatures. One of them does not have the same child nodes that are being commanded by the animator so it deletes those animation tracks in order to not receive a bunch of errors. However in doing so, it deletes the animations for all creatures using that instance!

It would seem the animation tracks are not properly instantiated and are instead shared between everything that instantiates the animation player. That may be a bug on it’s own, but for now I’d like to work around it. The easy way to do so would be to discard the instance of the animation player from the one node that differs.

How would I be able to discard the instance from code so the different creature can merely have a copy of the instance to modify for itself?

Is this the same issue? https://forum.godotengine.org/13573/running-multiple-animation-player-nodes

Possibly this if you need to do it from code https://forum.godotengine.org/9190/make-a-resource-unique

Grasping a little bit here - but maybe some pointers

dj_pale | 2017-04-28 10:15

No longer a problem, but certainly confusing that animations are considered resources. Because of that they can’t so easily be modified without shared instances being affected. For the record I did not solve this problem. I made two separate nodes to instantiate for the different creatures involved. I then modified the animation tracks from there.

Scene inheretence might’ve saved me the trouble, but sadly there is not much of any documentation on how to implement this. I decided to go the safe & easy route for now.
Thanks to Karoffel & dj_pale for their solutions & help.

Aaron M | 2017-04-28 16:30

You can save animations as resource files then load them on empty AnimationPlayers, resources are easy to edit with a text editor too if you have many similar animations.

eons | 2017-04-29 02:09

I tried that and it would still modify tracks over the same file. If I use separate animations then they aren’t shared. I decided to separate them completely with different copies of the animations & animation players.

Aaron M | 2017-05-01 11:36

:bust_in_silhouette: Reply From: Aaron M

Animations are treated as resources, that is the source of the problem. If one deletes tracks from an animation from an instanced animation player that is instantiated to multiple objects, then that track modification will affect all other instances. Therefore I will have to design my characters in a way to where they use separate animations in the case of there being missing nodes without modifying the tracks directly.