Skip to content

example for Godot Multiplayer in the browser with websockets

Notifications You must be signed in to change notification settings

cdreier/godot-bricks-mp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godot Bricks Multiplayer

For our winterplenum at inovex, i created this small example for a dedicated Godot Multiplayer server in the browser with websockets.

There are 3 projects

  • The main game at the root of this repository
  • The realtime-server, a second Godot project for the dedicated websocket server
  • The brickserver, written in go for a lightweight persistence and event storage

This go server uses a boltdb via bolthold - to persist the current world and additionally persists all events in a second db, so you can replay all the brick-events and watch some timelaps :)

timelaps

Code!

Most of the network code are in the Connection files. The important part is, to set the websocket client and server as network_peer to get everything working with Godots high level multiplayer API

After learning in DinoPoker that a position sync on every frame is working and looks smooth (but kills a small server with a few players), i tested to interpolte the positions with a timer only 10 times per second. Perhaps this can be done a bit more clever?

Controls

WASD - movement
E - drop a brick
Q - toggle camera
SPACE - jump
Click - delete brick
Colorpicker... pick colors

basics

With the on/off toggle on the bottom right corner, you can toggle a grid movement where you only move in half-brick steps, so you can better control the position and build acutally something that is more than a big colored pile ;)

Offline

to just test it, there is an offline, non-persistent version, starting when no servers are found to communicate with.

Deployment

i put together a simple docker-compose file ( also found in https://github.com/cdreier/godot-bricks-mp/tree/master/docker )

just do a HTML5 export into the docker/export folder and run docker-compose up

after everything is up, you can test it at http://localhost:8000/?server=ws://localhost:8001

version: "3.2"

services:
  server:
    image: drailing/godot-bricks-mp-rt:latest
    ports:
      - 8001:5000
    networks:
      - storage-net
    environment:
      - BRICK_SERVER=http://brickserver:8080

  brickserver:
    image: drailing/godot-bricks-mp-brickserver:latest
    volumes:
      - ./data:/app/data
    networks:
      - storage-net

  web:
    image: drailing/static_file_server:latest
    ports:
      - 8000:80
    volumes:
      - ./export:/www

networks:
  storage-net:

About

example for Godot Multiplayer in the browser with websockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published