Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | EmergencyRoomPanda |
So, I am making a basic typing game.
My current main script creates an instance of a letters scene for use in the main scene.
I need to keep track of the random letter or word generated for removal on user inputs.
My primary question is how you go about accessing members of an instanced class.
Currently:
func _on_WordsTimer_timeout():
$WordsPath/WordSpawnLocation.set_offset(randi())
words = Words.instance()
add_child(words)
print($words.letter)
words.position = $WordsPath/WordSpawnLocation.position
The print statement is my primary point of questioning here.
On running my project with no print statement characters spawn as expected.
With the print statement however I am getting
Invalid get index 'letter' (on base: 'null instance')
How should I go about accessing member variables of an instanced child node for usage in the main or other scripts?