@onready var _skin = $skin
+@onready var _ray = $RayCast3D
@export_category("Appearance")
if _state == state.ALIVE:
velocity = global_transform.basis.z * speed
move_and_slide()
- if velocity.length() == 0:
+ if _ray_intersect_length() < 0.05 or velocity.length() < 0.02:
_explode()
+func _ray_intersect_length() -> float:
+ if _ray.is_colliding():
+ var point: Vector3 = _ray.get_collision_point()
+ var v: Vector3 = _ray.global_position - point
+ return v.length()
+ else:
+ return INF
+
func _explode() -> void:
_skin.visible = false
_state = state.DEAD