If each object has a collision object, like a RigidBody2D/StaticBody2D/KinematicBody2D, you can use the 2D DirectSpaceState and the intersect_point function to get any physics objects at a position in world space (untested code):
# the position you want to check:
var physics_check_position = Vector2(200, 200)
# a boolean to determine whether to check or not
# (so it doesn’t spam the console with print messages)
var perform_physics_position_check = true
func _physics_process(delta):
if (perform_physics_position_check == true):
perform_physics_position_check = false
# the code to check the position below:
var space_state = get_world_2d().direct_space_state
var bodies_at_pos = space_state.intersect_point(physics_check_position)
if bodies_at_pos.size() <= 0:
print (“nothing at pos: “, physics_check_position)
else:
Print (bodies_at_pos.size(), “ bodies at pos: “, physics_check_position)