0 votes

as the title says, while holding the directional button it will only move one, and not continually. here is my code and under the debugger says something but i cant seem to find the answer or figure out what they mean. i am new to coding so i would appreciate anything that can help me out, or direct me to a source that might be helpful in the future.

extends KinematicBody2D

var velocity = Vector2()

func physicsprocess(delta):
velocity.y += 0
if Input.isactionjustpressed("uiright"):
velocity.x = 100
elif Input.isactionjustpressed("uileft"):
velocity.x = -100
else:
velocity.x = 0

move_and_slide(velocity)

pass

W 0:00:10:0471 The function 'moveandslide()' returns a value, but this value is never used.
KinematicBody2D.gd:14

W 0:00:10:0471 The argument 'delta' is never used in the function 'setphysics_process'.
KinematicBody2D.gd:5

asked Aug 25, 2019 in Engine by deezy (39 points)
recategorized Aug 25, 2019 by deezy

1 Answer

0 votes
Best answer

The problem lies in the is_action_just_pressed cause this will only return true the first frame, the key got pressed and false afterward. What you should use instead is the is_action_pressed function.

Also see:

https://docs.godotengine.org/en/3.1/classes/class_input.html?highlight=is_action_just_pressed#class-input-method-is-action-just-pressed
And:

https://docs.godotengine.org/en/3.1/classes/class_input.html?highlight=is_action_pressed#class-input-method-is-action-pressed

answered Aug 25, 2019 by Nophlock (181 points)
selected Aug 26, 2019 by deezy

it works :D thanks :D

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 How to use this Q&A? before posting your first questions.