Basic movement doesnt work

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

var velocity = Vector2()

func _physics_process(delta):

if Input.is_action_pressed("ui_right"):
	velocity.x = 30
elif Input.is_action_just_pressed("ui_left"):
	velocity.x = -30
else:
	velocity.x = 0
move_and_slide(velocity)
	

moving to the right works perfectly but to the left it moves like 30 pixels to the direction inmediatly and then stops.
I been following a tutorial and everything is the same.

:bust_in_silhouette: Reply From: kidscancode

Left movement doesn’t work because you wrote the wrong command:

Input.is_action_just_pressed("ui_left")

versus

Input.is_action_pressed("ui_right")

is_action_just_pressed() only triggers on the first frame where you press the button, and will not trigger again until you release and press it again.

oh my bad. thank you

TomisOps | 2019-10-12 21:43