Chatgpt had introduced me to a method I did not know existed that restricts a body to a particular Area3d (or 2d I guess).

But it crashed before I could copy it down. Does anyone know what it might be? I'm not sure where or how to look and chatgpt is now giving me answers that don't include that method.

I wrote some code that prevents a Rect from moving outside of another Rect. I use it to prevent a Popup from being dragged outside of the viewport. I could post that if it would be helpful.

    I'm trying to keep a VR character inside a small area. I wonder if chat gpt made up the answer.

    I guess I might just need to use colliders

    Here's the relevant code (Godot 3.5.2-rc1):

    extends AcceptDialog
    ...
    onready var viewport_rect: Rect2 = get_viewport_rect()
    ...
    #warning-ignore:UNUSED_ARGUMENT
    func _process(delta: float) -> void:
    	
    	# Prevent dialog from being dragged out of viewport.
    	
    	var rect: Rect2 = get_rect()
    
    	# Check first if window is enclosed by viewport. The built-in method
    	# encloses() is theoretically faster than GDScript, and the condition will
    	# almost always be true, so it's worthwhile to do this check.
    	if viewport_rect.encloses(rect):
    		return
    
    	# Window is not enclosed by the viewport. Adjust window's position minimally
    	# so that window is enclosed by the viewport.
    	# Note that position must be set by changing the property rect_position, not
    	# the local variable rect.
    	if rect.position.x < viewport_rect.position.x:
    		rect_position.x = viewport_rect.position.x
    	elif rect.end.x > viewport_rect.end.x:
    		rect_position.x = viewport_rect.end.x - rect.size.x
    	if rect.position.y < viewport_rect.position.y:
    		rect_position.y = viewport_rect.position.y
    	elif rect.end.y > viewport_rect.end.y:
    		rect_position.y = viewport_rect.end.y - rect.size.y