Why when I delimit the camera of the world with clamp my player dissappears?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nilo

All is correct but when i put

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

position.x = clamp(position.x, 0, Limit.x)
position.y = clamp(position.y, 0, Limit.y)

The player dissappear

Do you have the camera as a child of the player? Where do you have this script, on the camera, or on the player? For me it seems like it gets teleported where you can’t see the player, but I may be wrong. Also, you could print out position.x and .y before clamping and after clamping to see if it got changed, and how.

1234ab | 2021-04-03 07:46