Hi there!
I’m using Godot Version 4.1.2 stable,
and the line
global_position = global_position.clamp(Vector2(0,0),screen_size)
gave me the error
Invalid type in function 'clamp' in base 'Vector2'. Cannot convert argument 2 from Rect2 to Vector2.
I then looked up Rect2 (https://docs.godotengine.org/en/stable/classes/class_rect2.html) and found the fitting property: end
.
So I added .end
behind screen_size
and then it worked flawlessly .
That last line looks now like this:
global_position = global_position.clamp(Vector2(0,0),screen_size.end)
Best regards, and i like this course