laser.gd 349 B

123456789101112131415
  1. extends Node2D
  2. func _ready():
  3. if $Line2D.get_point_count() == 2:
  4. $RayCast2D.position = $Line2D.get_point_position(0)
  5. $RayCast2D.set_cast_to($Line2D.get_point_position(1))
  6. else:
  7. print("Line2D has more than 2 points. Will not work")
  8. func _physics_process(delta):
  9. if $RayCast2D.get_collider():
  10. $RayCast2D.get_collider().queue_free()