
I’ve a raycast in my Participant node for a door scene with an Area3D collision form and each time it factors on the door I’ve a label saying "Open Door/Shut Door" however I do not know easy methods to make it disappear after I exit the collision form / transfer away from it.
That is the code for my raycast inside my participant.gd connected to my CharacterBody3D:
func _physics_process(delta: float) -> void:
handle_animations(delta)
update_tree()
# Raycast operate is named right here
item_interaction()
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Deal with leap.
if Enter.is_action_just_pressed("leap") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Raycast interplay operate
func item_interaction():
if interaction_raycast.is_colliding():
var raycast_collider = interaction_raycast.get_collider()
if raycast_collider.is_in_group("openable_closeable_door"):
# Right here is the operate used to set "view_door_label" to true each time the raycast is colliding, that is the one I need to be set to false each time I exit the raycast collision / transfer away from the door.
raycast_collider.get_parent().get_parent().view_door_label(true)
raycast_collider.get_parent().get_parent().door_interact(proprietor)
After which I’ve a separate scene for my door with a separate script for the door open/shut and label capabilities:
extends Node3D
# Variable for door state the place false equals closed door and true equals open door.
var door_state_is_open: bool = false
@onready var door_animation: AnimationPlayer = $DoorAnimation
@onready var door_label: Label = $UserInterface/InteractionUIContainer/DoorLabel
# Right here is the operate used to set "view_door_label" to true each time the raycast is colliding, that is the one I need to be set to false each time I exit the raycast collision / transfer away from the door.
func view_door_label(label_visible: bool) -> void:
door_label.seen = label_visible
if door_state_is_open:
door_label.textual content = "Shut Door"
elif !door_state_is_open:
door_label.textual content = "Open Door"
func door_interact(_body) -> void:
if Enter.is_action_just_pressed("work together") && door_state_is_open == false:
door_animation.play("open_close_door")
door_state_is_open = true
await get_tree().create_timer(1.0).timeout
if Enter.is_action_just_pressed("work together") && door_state_is_open == true:
door_animation.play_backwards("open_close_door")
door_state_is_open = false
await get_tree().create_timer(1.0).timeout
I do not actually know easy methods to repair this situation. Any individual informed me to place
if !interaction_raycast.is_colliding():
return
at the beginning of the raycast operate inside my participant.gd then depart the remainder of the operate as is, however it did not work. Any thought easy methods to make this work? Any individual additionally steered a customized sign however I’m not in any respect accustomed to customized alerts.

