This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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:
https://pasteboard.co/JSkVc81.png

The layout of my scene tree is this:
https://pasteboard.co/JSkW8b1.png

Thank you for your help.

Godot version Godot v3.2.3.stable.official
in Engine by (30 points)

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

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.

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!

1 Answer

0 votes
Best answer

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!

by (30 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.