TLDR: Is it possible for an Animation Player (including call method tracks) to instantiate an object, add it to the scene tree, and then assign it to an existing animation track to be animated? (Use case is spawning a projectile and then animating its arc, and deleting it at the end)
I'm making a game inspired by Pokemon and I'm trying to figure out the best way to handle attack animations. The biggest hurdle I've come up against so far is that I want to have one place where I go to edit everything about each animation - I don't want to have to edit both code and an Animation Player's tracks, for instance.
However, my animations need to be able to add objects (usually projectiles) to the scene and then animate them. I don't know how to have an Animation Player have a track for an object that isn't in the scene yet, or to set that object to the track once it spawns. I don't mind writing some helper functions I can call with method call tracks to do this.
I'm aware I could just have the projectile object always in the scene and just turned off or sitting offscreen, then mess with it when the animation plays, but I don't know what all my animations will be yet and if one move uses 40 different projectiles it seems silly to have 40 objects sitting in the scene tree in every battle, just in case.
In the example below, I tried having the animation be its own scene, which I can instantiate and then delete when I'm done, but it means I can't animate the monsters already in the scene.
As a bonus, advice on ways to make it easier to animate attacks in both directions (player attacking opponent and opponent attacking player) would be welcome. Video is a proof of concept animation for reference.