0 votes

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 on
ground = false
var inputvector = Vector2()
func _physics
process(delta):
movimento.y += gravidade
var friccao = false
inputvector = Vector2.ZERO
if Input.is
actionpressed("uiright"):
if isAttacking == false || isonfloor() == false:
movimento.x = min(movimento.x+aceleracao, velocidademax)
if isAttacking == false:
$Sprite.play("Run")
$Sprite.flip
h = false
elif Input.isactionpressed("uileft"):
if isAttacking == false || is
onfloor() == false:
movimento.x = max(movimento.x-aceleracao, -velocidade
max)
$Sprite.fliph = true
$Sprite.play("Run")
else:
friccao = true
if on
ground == 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.is
actionpressed("uiattack") && isAttacking == false:
if isonfloor():
movimento.x = 0
$Sprite.play("Attack01")
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
movimento = move
andslide(movimento, salto)
if is
onfloor():
on
ground = true
else:
if isAttacking == false:
onground = false
if movimento.y < 0:
$Sprite.play("Jump")
yield ($Sprite, "animation
finished")
if Input.isactionjustpressed("uiattack"):
$Sprite.play("AirAttack")
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
else:
$Sprite.play("Fall")
if Input.is
actionpressed("uiattack"):
$Sprite.play("AirAttack")
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
pass
func _on
Spriteanimationfinished():
isAttacking = false"
asked Mar 9 in Engine by Ampv2002 (15 points)

1 Answer

0 votes

Looks like your walking animation is set to play even when your not on the ground. Try useing.

if is_on_floor():
    #All the code for the animation goes here

that's what I use.

answered Mar 10 by Merlin1846 (172 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.