The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

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 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)
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
isAttacking = true
yield ($Sprite, "animationfinished")
isAttacking = false
func _on
isAttacking = false"
in Engine by (17 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.

by (663 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.