I got a little network multiplayer demo up and running.
Movement is rough but I’ve read up on solutions to that.
This series of articles by Gabriel Gambetta were helpful: https://gabrielgambetta.com/client-server-game-architecture.html
I also found this source code helpful: https://github.com/seaciety/GodotMultiplayerDemo
That project does a lot by hand but I opted to use Godot’s MultiplayerSpawner and Multiplayer Synchronizer instead. It also does some fancy stuff like encoding to Protobuf which is pretty neat. Maybe a useful idea down the road.
I tinted the server blue. The other two are clients. Unforch this setup isn’t gonna work for Sneaky Elementals. Itch.io games can only use secure websockets for fast communication and they cannot host a websocket server. So I’ll definitely need to host the server somewhere else.
Some possibilities I considered:
- Godot on a server like AWS EC2 or Linode. Or a RaspberryPi.
- Godot in a container using AWS Fargate.
- Multiplayer as a Service: Beamable or Nakama or something like that.
What I want to test first, though, is if I can have one of the players run the server. Normally this is a no-no because of cheaters but my setup will be friends only (using a room code) and this is a casual two-player prototype, not Counter-Strike.
The Websocket server will be super light-weight and I could potentially re-use it.
…
First things first, I got Godot’s WebSocketPeer connecting to a Python server.
Next I’ll get the Python server to relay messages between two Godot clients.
Later I’ll switch to Godot’s WebSocketMultiplayerPeer instead. That way I can let the high-level multiplayer API handle a lot more of the work.