For all with the same problem here is how I solved it.
InitServer.gd
onready var server_tree = SceneTree.new()
func start_server():
server_tree.init()
server_tree.get_root().set_update_mode(Viewport.UPDATE_DISABLED)
# add your server scene (it needs to have the same name as the singelton which handles the client connection)
server_tree.change_scene_to(preload("res://Server/Server.tscn"))
set_process(true)
set_physics_process(true)
func _ready():
set_process(false)
set_physics_process(false)
func _process(delta):
server_tree.idle(delta)
func _physics_process(delta):
server_tree.iteration(delta)
func _exit_tree():
server_tree.finish()
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
methode.
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.