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.

godotengine.org | 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
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"
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.