Hello! it is me again.
I have another question and it is related to the animations of my platform character and it is that no animation works as it should or I don't know if I have indicated it incorrectly,
when the character jumps the jump animation doesn't work correctly, and the wall slide animation doesn't advance it's three frames but being on the wall only the first frame is shown and also the falling animation doesn't show as it should you can copy the code and make the animations so you can see why it doesn't work, when the character jumps the jump animation doesn't work correctly, and the wall slide animation doesn't advance it's three frames but being on the wall only the first frame is shown and also the falling animation doesn't show as it should you can copy the code and make the animations so you can see why it doesn't work, I would greatly appreciate it
Here is the code of the character
extends KinematicBody2D
export (int) var speed = 175
export (int) var jump_speed = -400
export (int) var gravity = 800
const wall_slide_speed = 82.5
const wall_slide_gravity = 400
var is_wall_sliding : bool = false
var velocity = Vector2.ZERO
func get_input():
velocity.x = 0
if Input.is_action_pressed("ui_right"):
velocity.x += speed
$AnimatedSprite.flip_h = false
$AnimatedSprite.play("RUN")
elif Input.is_action_pressed("ui_left"):
velocity.x -= speed
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("RUN")
elif velocity.y < 0:
$AnimatedSprite.play("JUMP")
elif velocity.y > 0:
$AnimatedSprite.play("FALL")
elif is_on_wall() and velocity.y > 0:
$AnimatedSprite.play("WALL_SLIDE")
else:
$AnimatedSprite.play("IDLE")
func _physics_process(delta):
get_input()
velocity.y += gravity * delta
velocity = move_and_slide(velocity, Vector2.UP)
if Input.is_action_just_pressed("ui_up"):
if is_on_floor():
velocity.y -= 400
$AnimatedSprite.play("JUMP")
if is_on_wall() and not is_on_floor():
if Input.is_action_pressed("ui_right") or Input.is_action_pressed("ui_left"):
is_wall_sliding = true
else:
is_wall_sliding = false
else:
is_wall_sliding = false
if is_wall_sliding == true:
velocity.y += wall_slide_gravity * delta
velocity.y = min(velocity.y, wall_slide_speed)
$AnimatedSprite.play("WALL_SLIDE")