Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | RodFire8181 |
For two days I have been trying to get the attack animation for my player sprite to play completely, but it will only play the first frame. I have moved things around in my code quite a bit, but to avail. I’ve looked around at possible reasons for this to keep happening and tried to fix those things, but it still won’t play completely.
This is my current code.
`func _physics_process(delta):
motion.y += GRAVITY
if Input.is_action_pressed("ui_right"):
if attacking == false:
motion.x = SPEED
$AnimatedSprite.flip_h = false
$AnimatedSprite.play("Run")
elif Input.is_action_pressed("ui_left"):
if attacking == false:
motion.x = -SPEED
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("Run")
else:
if attacking == false:
motion.x = 0
$AnimatedSprite.play("Idle")
if is_on_floor() && attacking == false:
if Input.is_action_pressed("ui_up"):
motion.y = JUMP_HEIGHT
if Input.is_action_just_pressed("ui_down") && attacking == false:
attacking == true
$AnimatedSprite.play("Attack")
if motion.x == 0:
if $AnimatedSprite.flip_h == false:
motion.x = 15
elif $AnimatedSprite.flip_h == true:
motion.x = -15
else:
if $AnimatedSprite.flip_h == false:
motion.x = SPEED + 15
elif $AnimatedSprite.flip_h == true:
motion.x = -SPEED + -15
else:
if motion.y < 0:
$AnimatedSprite.play("Jump")
else:
$AnimatedSprite.play("Fall")
motion = move_and_slide(motion, UP)`
Am I doing something wrong? Is there something I need to change or add?
Backticks ` only work for one-liner. Use the { } button to format a block of code.
Dlean Jeans | 2019-06-09 03:40
Thank you. Good to know.
RodFire8181 | 2019-06-09 17:54