I decided to start creating games. I used the manual "First Game in Godot" But the player does not move. Is there a problem in the code? Below is the code.

extends Area2D

export var speed = 400  # How fast the player will move (pixels/sec).
var screen_size  # Size of the game window.
func _ready():
	screen_size = get_viewport_rect().size
func _process(delta):
	var velocity = Vector2()  # The player's movement vector.
	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_down"):
		velocity.y += 1
	if Input.is_action_pressed("ui_up"):
		velocity.y -= 1
	if velocity.length() > 0:
		velocity = velocity.normalized() * speed
		$AnimatedSprite.play()
	else:
		$AnimatedSprite.stop()

I do not see a line that would actually use the velocity variant to move/translate the nodes position. You should keep reading the tutorial and the position updating should come up next.

@Megalomaniak said: I do not see a line that would actually use the velocity variant to move/translate the nodes position. You should keep reading the tutorial and the position updating should come up next.

I've already read this. But I do not know where to insert this code. Tried. Sometimes it's an error, and sometimes it just doesn't work. Can you specify where to write it?

Sorry for the mistakes. I'm not from here I have already found a solution

it should be added to the end of the _process() function.

extends Area2D

export var speed = 400  # How fast the player will move (pixels/sec).

var screen_size  # Size of the game window.

func _ready():
    screen_size = get_viewport_rect().size

func _process(delta):
    var velocity = Vector2()  # The player's movement vector.
    
    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_down"):
        velocity.y += 1
    if Input.is_action_pressed("ui_up"):
        velocity.y -= 1
    if velocity.length() > 0:
        velocity = velocity.normalized() * speed
        $AnimatedSprite.play()
    else:
        $AnimatedSprite.stop()
    
    position += velocity * delta    #HINT if there is something using delta it probably belongs in _process or _physics_process
    position.x = clamp(position.x, 0, screen_size.x)
    position.y = clamp(position.y, 0, screen_size.y)
a year later