![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | mextie-dev |
New to Godot. I am trying to make a simple text box appear when the player enters an Area, and disappear when it leaves it. This works fine, I have it set up like so:
extends TextureRect
func _ready(): #label hides itself upon scene start (doesnt work)
hide()
func _on_Area_body_entered(body): #label shows as player enters area
show()
func _on_Area_body_exited(body): #label hides when player leaves area
hide()
However, the text does not hide when the scene starts, leading to this:
The layout of my scene tree is this:
Thank you for your help.
Suspicious.
Make sure your TextureRect
is not referenced in any other scripts
Make sure your Player is not within the Area that triggers the TextureRect.show()
on scene start
As you already have the TextureRect
set to not visible these are the only two possible hindrances
Wakatta | 2021-03-13 01:27
Checked both suggestions, neither is the problem. The area that triggers the text is the door, and the player spawns well outside of the area that shows the text. I’m thinking it’s almost definitely a bug. I’m not too far into making the game so far, so I’m considering just starting over in Godot 3.1 or something, but are there any other possible reasons as to why this is happening? Thanks for the help.
mextie-dev | 2021-03-14 18:46
To anyone searching for this, I solved the problem. I wasn’t defining the body
that entered the Area3D as the player. Instead of:
func _on_enteringTheForest_body_entered(body):
enteringTheForest.show()
I needed to put:
func _on_enteringTheForest_body_entered(body):
if body == player:
enteringTheForest.show()
I defined player at the start of my scene as onready var player = $(whatever the name of your player node is)
Happy coding!
mextie-dev | 2021-03-19 19:59