- Edited
I asked a question previously as to why my multi state jump animation wouldn't play and an amazing person told me why it wouldn't work.
I fixed that and the animation will play however the first step of the jump animation the "jumpoff" still won't play it still stays in "idle" until the climax of the jump where it switches into the "jumploop" and then the rest of the multi state animation which works fine.
Could someone try to decipher this for me please?
P.S: sorry if it's obvious I'm rather new to programming
extends KinematicBody2D
var velocity = Vector2(0,0)
const SPEED = 140
const GRAVITY = 35
const JUMPFORCE = -600
func _physics_process(delta):
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMPFORCE
if not is_on_floor():
velocity.y = velocity.y
if velocity.y < -200: #going up
$AnimationPlayer.play("jumpoff")
elif velocity.y < -10:
$AnimationPlayer.play("jumploop")
elif velocity.y > -50 && velocity.y < 10.0: #transition
$AnimationPlayer.play("landing")
else: #falling
$AnimationPlayer.play("fallloop")
if Input.is_action_pressed("right"):
velocity.x = SPEED
$Sprite.flip_h = false
if is_on_floor():
$AnimationPlayer.play("walk")
elif Input.is_action_pressed("left"):
velocity.x = -SPEED
$Sprite.flip_h = true
if is_on_floor():
$AnimationPlayer.play("walk")
else:
if is_on_floor():
$AnimationPlayer.play("idle")
velocity.y = velocity.y + GRAVITY
velocity = move_and_slide(velocity,Vector2.UP)
velocity.x = lerp(velocity.x,0,0.1)