Animation player affects multiple nodes I don't want it to

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

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.

I figured out my problem. Even though I am using 2 different animation players, they both reference the same animation, “Move”. To fix my problem, I had to create a different animation for each child and have their animation players play the unique animation.

Beamer159 | 2016-10-20 04:53