Open Germenzi opened 2 months ago
Essentially the same as:
But with specific case where it would be used
Essentially the same as:
But with specific case where it would be used
Not exactly, I think. Passing parameters to PackedScene
still doesn't allow you to pass parameters into get_tree().change_scene_to_*
, because you don't call PackedScene.instantiate
directly.
It would be part of achieving it easily, by just passing those arguments when calling the instantiate
However the workaround is trivial enough that I don't see this being necessary, it isn't something that's hard to do in your project with your own specific needs, and with your specific setup you're probably better off with a custom solution
Describe the project you are working on
Multiplayer project where TCP should be used, so High-level multiplayer API isn't my choice.
Describe the problem or limitation you are having in your project
The problem is in switching between several scenes saving connection
StreamPeerTCP
instance. Some kind of autoload help to solve this problem, but this solution have some issues:And as for me, I need more than one connection and/or server (chat server/client, matchmaker, room server etc.) in one process. In my test project I wrote TCPNetworker manager (which is autoload and keeps all those problems), but it still doesn't fit me and that's off-topic. (Code is so messy, you know)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
I propose to add parameter(s) to
get_tree().change_scene_to_*
which could be accepted viaget_tree().get_scene_argument
, simple concept like cmdline arguments.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Example of changing scene when button pressed:
And in level-2 scene those arguments can be accepted as below:
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, it can be done using custom
SceneTree
like below:Is there a reason why this should be core and not an add-on in the asset library?
Generally - no. But being core feature it will be a lot more readable and reliable. Also custom
SceneTree
doen't support code autocompletion. Another reason is that scene files may contain 'neccesary' arguments which will be checked if this scene used inchange_scene_to_*
. And this will avoid using autoloads just to throw data to the next scene, removing unnecessary in other scenes nodes.