I am currently running through GODOTs own tutorial, and its game called “dodge the creeps”, which has some funny connotations these days.
Anyways - in the _process(delta) I have some input checking, and use of velocity and Vector2.
That is fine, and I understand that. At the end, the tutorial wants me to use a “position” to get the sprite to stay in the confines of a previously gotten screensize.
My issue is, that GODOT doens’t understand what “position” is - is that supposed to be a part of vector and I did something wrong? OR did the tutorial make a mistake here?
Here is the code:
export var speed = 400
Called when the node enters the scene tree for the first time.
screen_size = get_viewport_rect().size
var velocity = Vector2()
if velocity.length() > 0:
velocity = velocity.normalized() * speed
position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)
I know that usually these kind of errors are because I forgot something somewhere, but a word search on the page for “position” does not reveal anything previous to this use of the word, and I even tried copy pasting the tutorials code into my code instead, but get the same result.
Any help is appriciated!