var screensize = get_viewport_rect().size
screensize.x -= 100
screensize.y -= 100
global_position = global_position.clamp(Vector2(100,100),screensize)
lightweight way to clean up the edges of play window
var bumper = 100
var screensize = get_viewport_rect().size
screensize.x -= bumper
screensize.y -= bumper
global_position = global_position.clamp(Vector2(bumper,bumper),screensize)
var bumper_x = 55
var bumper_y = 20
var screensize = get_viewport_rect().size
screensize.x -= bumper_x
screensize.y -= bumper_y
global_position = global_position.clamp(Vector2(bumper_x,bumper_y),screensize)
a final example