Wavesonics / GodotClientServer

An example of how to setup a Client/Server architecture in Godot within a single projects.
MIT License
83 stars 1 forks source link

Error when lauching game #7

Open RamsaySummer opened 4 years ago

RamsaySummer commented 4 years ago

When I try to 'Start game' on client, I can't use the diffferent up down left movement and the server says:

MYNamePLAYER on_register_player: 87419819 Creating player in lobby Total players: 1 ERROR: Node not found: Game. At: scene/main/node.cpp:1381 ERROR: _process_get_node: Failed to get path from RPC: Game. At: core/io/multiplayer_api.cpp:256 ERROR: Invalid packet received. Requested node was not found. At: core/io/multiplayer_api.cpp:204 Entering game Creating player game object ERROR: Signal 'remove_player' is already connected to given method 'remove_player' in that object. At: core/object.cpp:1464

I am on W10 and i export the server project on the server folder '.exe and pck' and the client exe on client folder.

Is this a bad export of me ?

Wavesonics commented 4 years ago

Does the game crash or malfunction in some way? Or is it just printing these errors?

Drazuam commented 4 years ago

I am having the same issue. The windows server export does seems to malfunction - it will not take input from the clients. Of note, the server seems to hit this error while attempting to change the scene to ServerGame. I am attempting to export this via Godot 3.2.2 stable.

If there's any additional info I can help provide, let me know. I'm just getting my feet under me with Godot but hopefully I can be of help

edit: I've tried 3.2.3 as well but no luck

Drazuam commented 4 years ago

Some more information - Server seems to work correctly when run as a scene directly from Godot, but not in the exported .exe

Interesting... I wonder if we're messing up the export somehow? I didn't change any of the settings.

Drazuam commented 4 years ago

I figured it out! Line 31 of Game.gd may end up firing on the client before the server has loaded the ServerGame scene! In cases where this happens, the scene is unavailable and therefore is unable to be referenced by the client's RPC. I figured this out by placing a 500ms sleep before the RPC call, and it works fine. In theory, you could either preload the ServerGame node or send a signal to clients that the Game node is available, and only after that would they attempt RPCs

Wavesonics commented 4 years ago

Ah good catch! I never encountered this in my own project because there is a count down in the lobby when the game starts, and the server goes before the count down starts.