+4 votes

I want to programm a card game.
The architecture i want to use is that all game logic is handled by a server and the grafic and gui stuff by a client.
But the programm should include server and client in the same project so that evryone can start a server to play with friends.

I found an example using multiple scene trees for godot 2

I tried to adapt this for godot 3
But when starting a new scene tree it seems to become the active render target directly.

So I can't start a scene tree to start the server on because the client scene tree is not rendered anymore. But the client process is still called.

In the example


is called to do this but it seems to happen automaticly in godot 3.

I have to use seperate scene trees because one scene tree can handle one network peer for the highlevel networking.

Godot version 3.2.3.stable
in Engine by (336 points)

I am trying to solve a similar problem. I'm considering submitting a feature request to somehow separate the network binding from SceneTree so it's easier to build dedicated servers with separate listeners for each functional domain (e.g. user authentication, lobby, game play, etc). It will allow servers to be better structured, more secure, better support multiple instances, etc.

I'm interested in how you adapted the scenetree_holder example to Godot 3.2.3. Would you share that part of your code?

3 Answers

+1 vote
Best answer

Maybe server_tree.get_root().set_update_mode(Viewport.UPDATE_DISABLED)? Just guessing.

by (330 points)
selected by

This solves the problem with the drawing but i still dont get rpc to work. But i guess this is an other problem.

Ok I got rpc to work as well. Thx

+1 vote

For all with the same problem here is how I solved it.


onready var server_tree = SceneTree.new()

func start_server():

  # add your server scene (it needs to have the same name as the singelton which handles the client connection)


func _ready():

func _process(delta):

func _physics_process(delta):

func _exit_tree():

To start the server call InitServer.start_server()
Inside of your Server.tscn you can start a server via the standart

get_tree().network_peer = peer


For rpc to work you have to know that the script which calls the rpc has a path. In your server scene you must have your script which handles the rpc under the same path.
So if you autoload your client manager as Networking its path is "root/Networking". Your Server.tscn is added to the root. If you name the root node of the scene its path is "root/Networking" as well. So rpc should work.

Tell me if I misunderstood the stuff with the paths but it works for me.

Note: I havent tested all details of this.

by (336 points)
0 votes

Use custom multiplayer for this purpose, which will allow you to run as many servers and clients you want in the same SceneTree.

Here is a demo project: https://github.com/LudiDorici/gd-custom-multiplayer

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