Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DarlesLSF |
Hello, when I walk with the player to the left, right, up and down directions, my animations work fine, but when I try to walk in the diagonal direction, dont play any animation, just stay in the idle frame.
And here’s the code:
var mover : Vector2
mover.x = Input.get_action_strength("direita") - Input.get_action_strength("esquerda")
mover.y = Input.get_action_strength("baixo") - Input.get_action_strength("cima")
if abs(mover.x) == 1 and abs(mover.y) == 1:
mover = mover.normalized()
var movendo = speed * mover
# sprites da movimentação
if mover.x == 1:
$Sprite/anims.play("direita")
frame = 4
if mover.x == -1:
$Sprite/anims.play("esquerda")
frame = 10
if mover.y == 1:
$Sprite/anims.play("baixo")
frame = 7
if mover.y == -1:
$Sprite/anims.play("cima")
frame = 1
if mover.x == 0 and mover.y == 0:
$Sprite/anims.stop()
$Sprite.frame = frame
move_and_slide(movendo)
How can I fix that?