func _ready():
# Connect the visibility changed signal
connect("visibility_changed", self, "_on_visibility_changed")
# Initial activation/deactivation based on visibility
if not is_visible_in_tree():
deactivate()
func _process(delta):
# Optionally, you can check visibility here if needed
if not is_visible_in_tree() and is_processing():
deactivate()
func _on_visibility_changed():
# Called when visibility changes
if is_visible_in_tree():
activate()
else:
deactivate()
func deactivate():
hide()
set_process(false)
set_physics_process(false)
set_process_unhandled_input(false)
set_process_input(false)
func activate():
show()
set_process(true)
set_physics_process(true)
set_process_unhandled_input(true)
set_process_input(true)
func _on_Lava_body_entered(body):
get_tree().reload_current_scene()
func _on_hide_pressed():
$Lava.hide()
func _on_show_pressed():
$Lava.show()