+2 votes

Hello. I am a beginner when it comes to Godot and GDScript, and have been trying to make a simple platformer. I have added in the jump and everything works so far, my only problem is the jumping and falling animations. The fall works ok, but the jump animation instead pauses on the first frame and doesn't change while it is played. Here is my code attached to the player:

extends "res://Scripts/Actor.gd"
onready var animatedSprite = $AnimatedSprite

var velocity = Vector2.ZERO
var maxRun = 100
var runAccel = 800
var gravity = 1000
var maxFall = 160
var jumpForce = -160
var jumpHoldTime = 0.2
var localHoldTime = 0

func process(delta):
var direction = sign(Input.get
actionstrength("uiright") - Input.getactionstrength("uileft"))
var onGround = global
position.y >= 160

var jumping = Input.is_action_pressed("Jump")
if jumping && onGround:
    velocity.y = jumpForce
    localHoldTime = jumpHoldTime
elif localHoldTime > 0:
    if jumping:
        velocity.y = jumpForce
        localHoldTime = 0

localHoldTime -= delta

if direction > 0:
    animatedSprite.flip_h = false
elif direction < 0:
    animatedSprite.flip_h = true

if direction != 0:

if !onGround:
    if velocity.y < 0:

velocity.x = move_toward(velocity.x, maxRun * direction, runAccel * delta)
velocity.y = move_toward(velocity.y, maxFall, gravity * delta)

moveY(velocity.y * delta)
moveX(velocity.x * delta)

(Sorry for the bad formatting)
Also, the part that handles movement is in another script.
Any help on how to fix the jump animation would be really helpful and thanks for reading

Godot version 3.4.4
in Engine by (14 points)

Please log in or register to answer this question.

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.
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 webmaster@godotengine.org with your username.