Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Erto |
Hello! Im trying to make it so I can play my sword animation while I jump and move. For some reason i can move and jump initially. But if I press my sword attack I can no longer move or jump. Just play the sword animation. Would appreciate some help!
var canSlash = false
func _ready():
pass
func _process(delta):
var movement = Input.get_action_strength(“ui_right”) - Input.get_action_strength(“ui_left”)
if movement != 0 && canSlash == false:
velocity.x += movement * speed * delta
$anim.flip_h = movement < 0
$anim/anima.play(“WALK”)
elif velocity.x == 0 && velocity.y < 0 && canSlash == false:
$anim/anima.play(“JUMP”)
elif velocity.x == 0 && velocity.y > 30 && canSlash == false:
$anim/anima.play(“FALL”)
elif movement == 0 && canSlash == false:
velocity.x = 0
$anim/anima.play(“IDLE”)
if velocity.y > 350:
get_tree().reload_current_scene()
if is_on_floor() && Input.is_action_just_pressed("ui_accept") && canSlash == false:
velocity.y -= jump
$anim/anima.play("JUMP")
elif velocity.y < 0 && velocity.x != 0 && canSlash == false:
$anim/anima.play("JUMP")
elif velocity.y > 30 && velocity.x != 0 && canSlash == false:
$anim/anima.play("FALL")
if Input.is_action_just_pressed("ui_sword1"):
canSlash = true
$anim/anima.play("SWORD1")
if is_on_floor() && canSlash == true:
$anim/anima.play("SWORD1")
elif velocity.y < 0 && velocity.x != 0 && canSlash == true:
$anim/anima.play("SWORD1")
elif velocity.y > 0 && velocity.x != 0 && canSlash == true:
$anim/anima.play("SWORD1")