Whenever I move my character mid-air the jump animations freezes, but when I don't move the animation plays just normal I would like some help here. Here's the code (P.S: Im using Animated Sprites):
extends KinematicBody2D
const salto = Vector2(0, -1)
const gravidade = 15
const velocidademax = 150
const altura = -700
const aceleracao = 50
var movimento = Vector2()
var isAttacking = false
var onground = false
var inputvector = Vector2()
func _physicsprocess(delta):
movimento.y += gravidade
var friccao = false
inputvector = Vector2.ZERO
if Input.isactionpressed("uiright"):
if isAttacking == false || isonfloor() == false:
movimento.x = min(movimento.x+aceleracao, velocidademax)
if isAttacking == false:
$Sprite.play("Run")
$Sprite.fliph = false
elif Input.isactionpressed("uileft"):
if isAttacking == false || isonfloor() == false:
movimento.x = max(movimento.x-aceleracao, -velocidademax)
$Sprite.fliph = true
$Sprite.play("Run")
else:
friccao = true
if onground == true && isAttacking == false:
$Sprite.play("Idle01")
if Input.isactionjustpressed("uiup"):
if isAttacking == false && isonfloor() == true:
movimento.y = altura
inputvector.y = 1
if friccao == true:
movimento.x = lerp(movimento.x, 0, 0.2)
else:
if friccao == true:
movimento.x = lerp(movimento.x, 0, 0.89)
if Input.isactionpressed("uiattack") && isAttacking == false:
if isonfloor():
movimento.x = 0
$Sprite.play("Attack01")
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
movimento = moveandslide(movimento, salto)
if isonfloor():
onground = true
else:
if isAttacking == false:
onground = false
if movimento.y < 0:
$Sprite.play("Jump")
yield ($Sprite, "animationfinished")
if Input.isactionjustpressed("uiattack"):
$Sprite.play("AirAttack")
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
else:
$Sprite.play("Fall")
if Input.isactionpressed("uiattack"):
$Sprite.play("AirAttack")
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
pass
func _onSpriteanimationfinished():
isAttacking = false"