Every animation on my player is playing except Jump and Attack

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By prodtmk

All of my “is pressed” codes work just fine but none of the “is just pressed” codes work. What am i doing wrong? I’m making a 2D platformer
Heres my player code:

extends KinematicBody2D

const UP = Vector2(0, -1)
const GRAVITY = 15
const MAX_SPEED = 125
const JUMP_HEIGHT = -300
var collision_info = move_and_collide(Vector2(0,0))
var motion = Vector2()

func _physics_process(delta):
motion.y += GRAVITY
var friction = false

if Input.is_action_pressed("ui_right"):
	motion.x = min(motion.x+ACCELERATION, MAX_SPEED)
	$Sprite.flip_h = false
elif Input.is_action_pressed("ui_left"):
	$Sprite.flip_h = true
	motion.x = max(motion.x-ACCELERATION, -MAX_SPEED)
	friction = true

if is_on_floor():
	if Input.is_action_just_pressed("ui_up"):
		motion.y = JUMP_HEIGHT
	if friction == true: 
		motion.x = lerp(motion.x, 0, 0.18)
	if motion.y < 0:

if friction == true: 
	motion.x = lerp(motion.x, 0, 0.05)

if Input.is_action_just_pressed("ui_attack"):

motion = move_and_slide(motion, UP)
:bust_in_silhouette: Reply From: nightrobin

It may already played the animation and ended, so you have to loop the animation.

Also, it is better to put the play animation inside the _process or _physics_process and have a variable checker there that is changed depending on the user’s input.


var isJumping= false

func _ready():

func _input(delta):
    if Input.is_action_pressed("ui_up"):
        isJumping= true

    if Input.is_action_just_pressed("ui_up"):
        isJumping= false

func _process(delta):
    if isJumping: