func _process(delta):
var new_vector = Vector2()
if Input.is_action_just_pressed('ui_right'):
new_vector += Vector2.RIGHT
if Input.is_action_just_pressed('ui_left'):
new_vector += Vector2.LEFT
if Input.is_action_just_pressed('ui_down'):
new_vector += Vector2.DOWN
if Input.is_action_just_pressed('ui_up'):
new_vector += Vector2.UP
new_vector = new_vector.normalized()
position += delta * MOVE_SPEED * new_vector * 0.07
The normalized() method makes sure that you don’t move faster in the diagonal directions, since 1 up and 1 right moves you further than just 1 in those directions alone.
Also note that you had the wrong operator in the key up: it should have been –= not +=
HTH
That works exactly as intended, but for my sprite GUI coverin my TileMap: it’s jerkin at every move… Maybe due to the fact that it’s child of my player and camera, but i cannot put it elsewhere… Any idea?