I have a Scene structured like this:
Node2D
Sprite
AnimationPlayer
The animation player has an animation called "Move" with only one track for changing the Node2D position. I create 2 instances of this scene in my Game scene, set them to different positions, and then try to utilize both of their animation players like so:
func _ready():
var scene = load("res://Node2D.tscn")
child1 = scene.instance()
child2 = scene.instance()
add_child(child1)
add_child(child2)
child1.set_pos(Vector2(100, 100))
child2.set_pos(Vector2(200, 200))
child1.move(Vector2(200, 100))
child2.move(Vector2(300, 200))
where the move function puts a keyframe for the current position at t=0, and another keyframe for the specified destination at t=1, like so:
func move(destination):
animation_player.get_animation("Move").track_insert_key(0, 0, get_pos())
animation_player.get_animation("Move").track_insert_key(0, 1, destination)
animation_player.play("Move")
My problem is that with this, child1 moves along the same animation path as child2, even though it has its own animation player. I have no idea why they don't both move along their own animation paths.