Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eweninja/godot-firebase-multiplayer-example
Example project for multiplayer game with GodotFirebase, Realtime Database and Godot 4.
https://github.com/eweninja/godot-firebase-multiplayer-example
firebase godot4 godotengine multiplayer realtime
Last synced: 7 days ago
JSON representation
Example project for multiplayer game with GodotFirebase, Realtime Database and Godot 4.
- Host: GitHub
- URL: https://github.com/eweninja/godot-firebase-multiplayer-example
- Owner: eweninja
- License: mit
- Created: 2023-06-30T18:59:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-06T19:26:49.000Z (over 1 year ago)
- Last Synced: 2024-11-12T07:35:43.483Z (2 months ago)
- Topics: firebase, godot4, godotengine, multiplayer, realtime
- Language: GDScript
- Homepage:
- Size: 168 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# godot-firebase-multiplayer-example
**Work in progress**.
Example project in Godot 4.1 using [GodotFirebase](https://github.com/GodotNuts/GodotFirebase).
Firebase Realtime Database shared multiplayer with authority for own player.## Reason
- I'm creating this project for reference, as a basic example of creating multiplayer in Godot 4 using Firebase (mostly Firebase Realtime Database).
- Learning. 😊## About project
- Anonymous login.
- Setting nickname.
- Creating lobby room.
- Joining lobby room.
- Matchmaking:
- Search for open rooms:
- If open room exists, join it.
- Else create new open room and wait for other players.
- In lobby room:
- Starting game.
- Leaving room.
- Text chat (optionally).
- Gameplay:
- Spawning players:
- Self.
- Remote.
- Sending player position.
- Receiving remote players position.
- Broadcasting player actions.
- Host migration.
- Game end:
- Showing results.
- Going back to lobby.## Database workflow
**How are players added to db?**
Players are added after loggining in. Every player is updating themself every 90 s.**How are players removed from db?**
Player `updated_time` property is compared with actual time. If diff is more than 120 s - player is removed.**How are rooms added to db?**
Rooms are added then logged in player perform `Create Room` action. ~~Room has property `marked_to_remove = false`.~~ Rooms are updated by player host every 90 s.**How are rooms removed from db?**
~~Rooms are first marked as `marked_to_remove = true` and then removed. They are makred then players number is 0 (`roomId.players == {}`).~~
Same as player.**How are sessions added to db?**
-**How are sessions removed from db?**
To include everything in one project, every game instance are making cleanups for `players`, `rooms` and `sessions`.
## Todo
- [x] Add login (anonymous).
- [x] Add simple player scene.
- [x] Add player nicknames.
- [ ] Lobby rooms.
- [ ] Matchmaking.
- [ ] Simple "gameplay".
- [ ] Game end.
- [ ] Change naming to more reasonable, like room vs lobbby.
- [ ] Refactor code.## Database structure
```json
{
"rooms": {
"$roomId": {
"room_name": "room-name",
"created_time": 0,
"updated_time": 0,
"is_running": false,
"players": {
"$playerId": {
"is_host": true,
"nickname": "",
"current_points": 0,
"is_ready": false,
"updated_time": 0
}
}
}
}
}
```- Players | Keeps track of online players.
- Rooms | Keeps track of lobby rooms.
- Sessions | Keeps track of ongoing games.