0 votes

hello,
I want to expand a nodeA (adding child) from a script attached to this nodeA :
Ok I know it is not possible to do it directly but I cannot understand or make work any suggestion found on the net.

calldeferred produce nothing
request
ready():, I got no clue where to put it

func _ready():
var position= Position3D.new()
position.set_name("posi")
add_child(position)
print_tree_pretty()

the most upsetting thing is that printtreepretty print exactly what I want to do. but nothing appear on the right panel

when I use this
call_deferred("add_child",position)
print_tree does not even show any added child
thx

asked Aug 10 in Engine by Asoth (35 points)
edited Aug 11 by Asoth

In which context are you doing this? Is it in game or in editor with tool script?

it is actually a code that worked properly as a tool script.
I want to make it do what he is supposed to do on "play" instead of "run".
and splitting my code into each node instead of putting everything on one big tool script sound less cumbersome.
(i want to create the whole hierarchy of node by script)

There is almost no difference between tool and game though. tool just means the node runs in game AND editor. call_deferred("add_child",position) should have worked. When I test your code it works as well, it prints this:

 ┖╴Node
    ┖╴posi

well, the "posi" node show up when printed but do not show up in the inspector, at least for me.

wait what is the heck with the "remote scene tree" is it actually normal nothing appear in the inspector when I add node from the script while running ?
https://godotengine.org/qa/3619/there-are-have-some-ways-view-scene-tree-when-project-running

1 Answer

0 votes

Sounds like I was just unaware of the existence of remote inspector over local one.
I will investigate what it is. is it mentioned somewhere I overlooked in the doc ?
I would be surprised to be only one to struggle with that.

answered Aug 11 by Asoth (35 points)

When you run the game, it runs in a separate process. What the editor shows you is the scene as it is in the resources of your game. If you want to see the scene as it is WHILE you play the game, use the remote scene tree tab in the editor. It's not turned on automatically because it's not needed often, and as a debugging tool it takes a small hit on performance.
Are you coming from Unity by any chance?

thank so much you for clarification,
I am not really coming from unity , just tried few hours on unity and discovered that godot exist, so I came to godot.

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.