0 votes

I have a reference to a node:

var player
func _ready():
    player = get_node("/root/World/map/Player")

and an array:

var dialogue_1 = [
    "Nice to meet you Somebody",

but when I print:


it gives me Null, what is the proper way to store a reference to a node inside a list?

asked May 12 in Engine by Kia Azad (16 points)

2 Answers

+1 vote

It has nothing to do with storing it in an array. If you try print(player) in _ready() you'll see it's null as well.

You can't call up the tree in _ready() because wherever this node is, "World" is not ready yet. Nodes become ready in reverse tree order - children first, parents last.

answered May 12 by kidscancode (17,180 points)

I've already tested print(player.name) and got player so I'm pretty sure that part works

0 votes

Found the problem, my dialogue was defined after the _ready() block but outside it, once I've moved it inside the problem was solved.

answered May 12 by Kia Azad (16 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 How to use this Q&A? before posting your first questions.