The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

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

in Engine by (114 points)
edited by

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.

by (114 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 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.