22 lines
589 B
GDScript
22 lines
589 B
GDScript
extends RayCast3D
|
|
|
|
# Keep track of what we were just looking at
|
|
var current_target: Object = null
|
|
|
|
func _physics_process(_delta: float) -> void:
|
|
if is_colliding():
|
|
var collider = get_collider()
|
|
if current_target != collider:
|
|
_clear_current_highlight()
|
|
current_target = collider
|
|
if current_target.has_method("startHighlight"):
|
|
current_target.startHighlight()
|
|
else:
|
|
_clear_current_highlight()
|
|
|
|
func _clear_current_highlight() -> void:
|
|
if current_target != null:
|
|
if current_target.has_method("stopHighlight"):
|
|
current_target.stopHighlight()
|
|
current_target = null
|