Hi, I've built a demo from scratch.
Scene set ups.
Main Scene has 4 detection areas, 4 objects to be dragged around, floor, camera, light, and a static body 3D to keep the object on the same height as detection areas when dragging.
Detection Scene is a Area 3D with mesh as visual indicator and a 5x1x7 collision shape 3D. Collision mask set to 3.
3D Obejct is a Rigid Body 3D with 2x2x2 collision shape and mesh. Collision layer set to 1, 2, 3
Scripts
3D object
Stores a 3d coordinate that the object will return to
Check to see if the object is inside of a detection area
class_name Collider
var detected: bool = false
var memorized_position: Vector3 = Vector3.ZERO
func _ready():
memorized_position = global_transform.origin
Detection Area
Check if the body entered is desired object
Set the condition accordingly and print to check for the correct interaction
func _on_body_entered(body):
if body is Collider:
body.detected = true
print(body.name, " entered: ", self.name)
func _on_body_exited(body):
if body is Collider:
body.detected = false
print(body.name, " Left: ", self.name)