you can use the playing property
if not AnimationPlayer.playing: play
also the idle will be read 1st and always since its the top of physics
do if button: play else: idle
I usually just separete a function to control animations... probably not the best way (a state machine would be a lot better) but it works for my small project
##------------------------Animation control - start------------------------------------
func _animation_control():
##----------CHASE COLORS [animation player]
if PlayerData.has_suit or is_bribed or no_search_mode:
$ChaseColors.play("patrol")
if PlayerData.has_weed and not PlayerData.has_suit and not is_bribed and not no_search_mode:
$ChaseColors.play("siren")
#add a visible siren effect here
##-----------SPRITE ANIMATION
if motion.x < 0: #left
$Sprite.flip_h = false
$Sprite/tookroach.flip_h = false
$Sprite/tookroach.position = Vector2(-8,9)
if is_bribed:
$Sprite.play("bribed")
elif PlayerData.has_suit and not is_bribed and not no_search_mode:
$Sprite.play("suit_effect")
elif has_snorted:
$Sprite.play("patrol_morph")
else:
$Sprite.play("patrol")
elif motion.x > 0: #right
$Sprite.flip_h = true
$Sprite/tookroach.flip_h = true
$Sprite/tookroach.position = Vector2(8,9)
if is_bribed:
$Sprite.play("bribed")
elif PlayerData.has_suit and not is_bribed and not no_search_mode:
$Sprite.play("suit_effect")
elif has_snorted:
$Sprite.play("patrol_morph")
else:
$Sprite.play("patrol")
else: #idle
if PlayerData.dropped_coke and motion.x == 0: #if cop reached coke
$Sprite.play("snort") #snort it
else:
$Sprite.play("idle")
##--------------------------Animation control - end--------------------------------
as you see the idle animation is the very last else/else in the function