sensor_ray.gd 696 B

12345678910111213141516171819202122232425262728293031
  1. extends RayCast
  2. export var maxlength = 10.0
  3. var distance = 0
  4. # Declare member variables here. Examples:
  5. # var a = 2
  6. # var b = "text"
  7. # Called when the node enters the scene tree for the first time.
  8. func _ready():
  9. cast_to = Vector3(0,-maxlength,0)
  10. func _physics_process(delta):
  11. if !is_colliding():
  12. $intersection.visible = false
  13. $ray_handle.scale = Vector3(0,distance,0)
  14. return
  15. var collision_p = to_local(get_collision_point())
  16. distance = collision_p.length()
  17. $ray_handle.scale = Vector3(1,distance,1)
  18. $intersection.visible = true
  19. $intersection.translation = collision_p
  20. # Called every frame. 'delta' is the elapsed time since the previous frame.
  21. #func _process(delta):
  22. # pass