35 lines
1.3 KiB
GDScript
35 lines
1.3 KiB
GDScript
class_name VanishingBody extends StaticBody3D
|
|
|
|
var previous_vividness: float = 0
|
|
|
|
var scene = load("res://scenes/props/vanishing_body.tscn")
|
|
@onready var mesh: MeshInstance3D = $".".get_child(0)
|
|
@onready var collision: CollisionShape3D = $".".get_child(1)
|
|
#@onready var light: OmniLight3D = $".".get_child(2)
|
|
@onready var gpu_collision: GPUParticlesCollisionBox3D = $".".get_child(2)
|
|
@onready var dream_logic: Node = get_tree().get_first_node_in_group("Level")
|
|
@export var vivid_threshold : float = 50
|
|
|
|
func _ready() -> void:
|
|
previous_vividness = dream_logic.vividness
|
|
|
|
func _process(_delta: float) -> void:
|
|
##if the vividness is high enough the collision and mesh dissapear
|
|
if dream_logic.vividness > vivid_threshold: #and dream_logic.vividness != previous_vividness:
|
|
## Set collision shape to zero effectively removing it
|
|
collision.disabled = false
|
|
mesh.visible = true
|
|
if gpu_collision:
|
|
gpu_collision.visible = true
|
|
previous_vividness = dream_logic.vividness
|
|
#if light != null:
|
|
#light.visible = false
|
|
elif dream_logic.vividness < vivid_threshold: #and dream_logic.vividness != previous_vividness:
|
|
collision.disabled = true
|
|
mesh.visible = false
|
|
if gpu_collision:
|
|
gpu_collision.visible = false
|
|
previous_vividness = dream_logic.vividness
|
|
#if light != null:
|
|
#light.visible = true
|