overlap.gd 545 B

123456789101112131415161718192021222324
  1. extends Area2D
  2. func _process(delta):
  3. var bodies: Array[Node2D] = get_overlapping_bodies()
  4. for body in bodies:
  5. print(body.get_name(), " is overlapping with me")
  6. body.paint()
  7. force_body_scan()
  8. func _unhandled_input(event: InputEvent) -> void:
  9. if event is InputEventMouseMotion:
  10. var mouseMotion = event as InputEventMouseMotion
  11. position = mouseMotion.position
  12. func force_body_scan() -> void:
  13. set_position(get_position())
  14. func _on_body_entered(body: Node2D) -> void:
  15. print(body.get_name(), " entered in my area")
  16. body.paint()