I have a trouble with a 2D Godot Project.
I wrote the following code in the KinematicBody2D script:
extends KinematicBody2D
export var speed = 250
var motion = Vector2()
func _physics_process(delta):
motion = Vector2.ZERO
if Input.is_action_just_pressed("ui_left"):
motion.x = -speed
if Input.is_action_just_pressed("ui_right"):
motion.x = speed
if Input.is_action_just_pressed("ui_up"):
motion.y = -speed
if Input.is_action_just_pressed("ui_down"):
motion.y = speed
motion = move_and_slide(motion)
pass # Replace with function body.
The problem is that my player is only moving a few pixels and stops while I'm pressing the W, A, S, D or the arrow keys.
What I've done wrong?
Thank you all!