I'm trying to animate an object using keyframes programmatically, but I'm having trouble. Here is a sample that I think should work, but doesn't:
# I want to animate a sprite added via code, so let's add the sprite.
var sprite = Sprite.new()
sprite.set_texture(sprite_scene) # defined earlier
sprite.set_name("TestSprite") # Will be needed for the track path later
# Now that the sprite is added, I try to animate it
var animation = Animation.new()
# The animation is to move the sprite to the right for 1 second
animation.track_insert_key(0, 0, Vector2(600, 300))
animation.track_insert_key(0, 1, Vector2(800, 300))
# Now that I created the animation, I add it to my AnimationPlayer
# and play the animation. However, the animation does not play.
What seems to be wrong with this method?