0 votes

So, i have two questions:
But before, i need to say, im a beginner programmer, with only 1-2 years of experience
1. How i can get a node from the tree?
The tree is:
Game
-button1
-button2
-player
--playerSprite
I want to get the node 'button1' (it is a textureFrame bcs it isnt exactly a button) from the player script, so when the player spawns first, the button is not visible
I tried: gettree().getroot().getnode('Game').getnode('button1').setvisible(false)
But i get this error: "Attempt to call function 'get
root' in base 'null instance' on a null instance."

AND How i can check collision between an area2D and the player inside the player's script?
For example, i want to set the score to 1 when the player enters the area2D. But i want to do that in code

EDIT: I noticed Godot's "for" loop is using the syntax "for ... in ..."
I learned just the simple "for" loop
example: for (i = 0; i < x; i++)
What does "for... in..." loop?

in Engine by (402 points)

about the for loop thingy: for loops in godot are like for loops in python, you iterate through an array, not with an iteration like what you've learned... you can still set up a for loop the way you learned by using while loops

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.