The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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 physicsprocess(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
i think its something to do with the delta but im not sure.

Godot version 3.4.1
in Engine by (12 points)

1 Answer

+2 votes

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.

by (22,191 points)

It worked! thank you so much

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.