When add last three codes i get "Unexpected token: Indetifier: Position."

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Alone Developer
extends Area2D

export (int) var speed           # How fast will player move(pixels/seconds)
var screensize                   # Size of the game window.

func _ready():
	screenseize = 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
    position += velocity * delta
    position.x = clamp(position.x, 0, screensize.x)
    position.y = clamp(position.y, 0, screensize.y)

I edited your post to fix the code formatting. In future, please make sure to indent any code you paste by four spaces, or use the “Code” button in the formatting bar. I also removed “light2D” from the tags, as that didn’t seem at all applicable.

kidscancode | 2018-09-07 19:39

Hello. I have the same problem with the tutorial.
Your First Game — Godot Engine (3.0) documentation in English
The trouble is with position variable.
Could you explain it ?
Thank you very much !

vapi | 2019-03-07 14:49

The person above had several problems, mostly due to copy-and-pasting the code from the web page. What is your “trouble with position variable”? What is the error? What line? If I can’t see your code there is no way to answer your question. Start a new question and paste your code, making sure to use the formatting button so that it is readable.

kidscancode | 2019-03-07 15:23

:bust_in_silhouette: Reply From: kidscancode

I’m guessing from the way your copy-and-pasted code was misformatted, that your indentation on those last three lines is incorrect. They belong to the _process() function, and so they should be indented one more level (lined up with the other lines, such as the if statements).

Also, note that you’ve spelled screensize wrong in _ready()

yeah, following the tutorial is a bit wonky

thebaileybot | 2018-11-13 06:00