You should use two AnimationPlayers
as children of your Sprite
.
The first will play the main animations and the second will play the effect animations.
Here is the structure:
KinematicBody2D (or whatever your main node is)
Sprite
AnimationPlayer1 (for your spritesheet)
AnimationPlayer2 (for your effects)
You should create a reference to the first animation player and call it something like anim_player
and create a reference to the second animation player and call it something like effect_player
. Then you can reference them to play whatever animations you want in your code.
For example, in your main node script:
onready var anim_player = get_node("Sprite/AnimationPlayer1")
onready var effect_layer = get_node("Sprite/AnimationPlayer2")
func take_damage(amount):
# lower health
health -= amount
# play correct animations
anim_player.play("knockback_animation")
effect_player.play("blink")