Called when the node enters the scene tree for the first time.
Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
var velocity = Vector2()
if Input.is_action_pressed("ui_right"):
velocity.x += 1
if Input.is_action_pressed("ui_left"):
velocity.x -= 1
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
if Input.is_action_pressed("ui_down"):
velocity.y += 1
if velocity.length() > 0:
velocity = velocity.normalized() * speed
move_and_slide(velocity)
u need to use "Z Index" in Node2D conf. A node with a bigger Z index are over the others