why does my character move once when i hold a or d

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

i just started godot and i am looking at a tutorial and i got my character to move but i cant hold a or d (i will just move once) i hope someone can help here is the code

extends KinematicBody2D

const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXFALLSPEED = 2000
const MAXSPEED = 800
const JUMPFORCE = 300

var motion = Vector2()

func _ready():
pass # Replace with function body.

func _physics_process(delta):

motion.y += GRAVITY

if motion.y > MAXFALLSPEED:
	motion.y = MAXFALLSPEED
if Input.is_action_just_pressed("right"):
	motion.x = MAXSPEED
elif Input.is_action_just_pressed("left"):
	motion.x = -MAXSPEED
	motion.x = 0

motion = move_and_slide(motion,UP)
if is_on_floor():
	if Input.is_action_just_pressed("jump"):
		motion.y = -JUMPFORCE

and here is the tutorial https://www.youtube.com/watch?v=xFEKIWpd0sU
i think its something to do with the delta but im not sure.

:bust_in_silhouette: Reply From: kidscancode

Remove the “just” from is_action_just_pressed(), that only triggers once, immediately when the key is pressed. is_action_pressed() remains true as long as the key is being held.

It worked! thank you so much

RockSage | 2021-12-24 10:25