||Topic was automatically imported from the old Question2Answer platform.
const UP = Vector2(0,-1)
const GRAVITY = 13
const MAXFALLSPEED = 200
const MAXSPEED = 80
const JUMPFORCE = 300
const ACELL = 10
var motion = Vector2()
var facing_right = true
pass # Replace with function body.
motion.y += GRAVITY
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED
if facing_right == true:
$Sprite.scale.x = 1
$Sprite.scale.x = -1
motion.x = clamp(motion.x,-MAXSPEED,MAXSPEED)
motion.x += ACELL
motion.x -= ACELL
motion.x = lerp(motion.x,0,0.2)
motion.y = -JUMPFORCE
if motion.y < 0:
elif motion.y > 0:
motion = move_and_slide(motion,UP)
You mean player is not jumping and not animated ?
Show code for setting “is_on_floor” boolean
Or You mean player is jumping and not animated ?
That is because every frame You force the other 3 animations - left, right and idle. They are connected with all-time if statement , while jumping animation has a split frame to work - on action just pressed. So it works for one frame and is invisible for human eye, because in the next frame IDLE is forced again.
Could be loads of things. Add a print / line break to
$AnimationPlayer.play("Jump") and confirm it’s evaluating true. Check the name of the animation. Check it runs in the editor. Check it’s set to the beginning (if it’s at the end then playing won’t do anything).
I’d strongly recommend that you use AnimationTree. It’s one of the most powerful tools Godot offers. Takes a little getting used to but once you’re up to speed with it you’ll never dream of running animations without it. Up to you whether you use a state machine or a BlendTree - with the latter you can link your animations to the output node via a TimeScale and a “seek” so it’s easy to reset it in the editor.