-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Solved]A way to instance node with parameter #28712
Comments
If a packedScene's child node need get param who instance it, that will be a little problem, I should call every child in packed scene to change the var. The only way I think better is use the singleton to pass the param, but I think that's not naturally |
But you can set any properties after instancing and
There aren't any "async problems" with that. |
There's absolutely no "async problems" in setting a node's variable just after it's instantiation. |
Thank you guys, I see that a node wont instance child before adding to the tree |
I think if godot give a virtual function order, then everyone know how does it work. Just like the"ready", "enter tree", "draw", "input", "unhandled input", sometimes I feel confuse to the order they run |
Eh, is there any tutorial about that or any reference point in docs? If not, this could be changed to documentation issue. |
This would useful in scene testing. Because we don't know if pseudo-constructor is already called or not. Let this be Main.tscn's
Let this be Parts.tscn's
Having a instance with parameters would solve it because then I could just rename my init to _ready; And instance with bd.instance(1,1,"Y"). |
I can't agree more. Also, this can be used for the change_scene as change_scene(String path, ...) |
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine. The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker. If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance! |
<Godot 3.1>
Is there a way to pass some parameter to a node when instancing it? I mean the same time, not define a custom init function and then call it later, that will cause some async problem. Or can a node can know who instance itself, so we can use get_parent() to get param. I think if there is a way like than, code will be more simple. Or just because that will cause some performance issue?
The text was updated successfully, but these errors were encountered: