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
movimento.y += gravidade
var friccao = false
inputvector = Vector2.ZERO
if Input.is
if isAttacking == false || isonfloor() == false:
movimento.x = min(movimento.x+aceleracao, velocidademax)
if isAttacking == false:
h = false
elif Input.isactionpressed("uileft"):
if isAttacking == false || is
onfloor() == false:
movimento.x = max(movimento.x-aceleracao, -velocidade
$Sprite.fliph = true
friccao = true
if on
ground == true && isAttacking == false:
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)
if friccao == true:
movimento.x = lerp(movimento.x, 0, 0.89)
if Input.is
actionpressed("uiattack") && isAttacking == false:
if isonfloor():
movimento.x = 0
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
movimento = move
andslide(movimento, salto)
if is
ground = true
if isAttacking == false:
onground = false
if movimento.y < 0:
yield ($Sprite, "animation
if Input.isactionjustpressed("uiattack"):
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
if Input.is
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
func _on
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.