2023-12-09 22:45:18 +02:00
|
|
|
extends Function
|
|
|
|
class_name Occludable
|
|
|
|
|
|
|
|
var ray := RayCast3D.new()
|
|
|
|
@onready var player_camera: XRCamera3D = get_node("/root/Main/XROrigin3D/XRCamera3D")
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
ray.set_collision_mask_value(1, false)
|
|
|
|
ray.set_collision_mask_value(5, true)
|
|
|
|
get_parent().add_child.call_deferred(ray)
|
|
|
|
|
2024-01-30 18:47:38 +02:00
|
|
|
EventSystem.on_slow_tick.connect(_slow_tick)
|
|
|
|
|
|
|
|
func _slow_tick(_delta):
|
2024-03-12 13:34:44 +02:00
|
|
|
if player_camera.is_inside_tree() == false||ray.is_inside_tree() == false:
|
2024-02-27 17:37:22 +02:00
|
|
|
return
|
|
|
|
|
2023-12-09 22:45:18 +02:00
|
|
|
ray.target_position = get_parent().to_local(player_camera.global_position)
|
|
|
|
|
|
|
|
get_parent().visible = ray.is_colliding() == false
|