I’ve seen a few posts around this and maybe I’m just doing it weird, but I run into the issue where the idle animation overrides the attack animation. I am not using an animation player which could be part of the issue. Below is a copy of the animations code:
Play animations
if is_on_floor():
if direction == 0:
animated_sprite.play("Idle")
else:
animated_sprite.play("Run")
else:
animated_sprite.play("Jump")
if Input.is_action_just_pressed("Attack"):
animated_sprite.play("Attack")
animated_sprite.stop()
The stop by itself doesn’t pause the idle animation, but if I fill it is with “Idle” the game crashes. I’ve also tried if_playing (“Attack”) = True, animated_sprite.stop(“Idle”) and it crashes.
Any help is appreciated! Happy to send the rest of the code if necessary.
The attack animation is being played for one frame before being overridden by the idle/run/jump animation the next frame. You’ll need to keep track of the animation being played before trying to play any of those animations.
Right, so what would pausing those animations/prioritizing the attack animations look like? I’ve been trying to follow tutorials but it just results in a crash
if not (animated_sprite.is_playing() and animated_sprite.animation == "Attack"):
if is_on_floor():
if direction == 0:
animated_sprite.play("Idle")
else:
animated_sprite.play("Run")
else:
animated_sprite.play("Jump")
if Input.is_action_just_pressed("Attack"):
animated_sprite.play("Attack")