Netcode Update - Inventory
π€ NetCode update
Thinking through how to keep game state in sync with network state, I had to choose a pattern to stay organized.
The problem:
- No consistent state change interface
- State changes were not clear if it triggers a network update, or comes from a network update
- Signals were emitted from any object or Globals without reason
- βUpdate/Updatedβ Signals cause co-recursive signal emission
Take the Inventory as an example, player can add, remove, or update an inventory, and the items in the inventory need to be synchronized to all other connected players.
Before - not following a pattern
βββββββββββββββββ βββββββββββββββββββββββββββββ
β Inventory.gd β β Network.gd β
β β β β
β add() ββββββββ€βΊsend_add() β
β remove() ββΌβΌβΌβΌβΌβΌβ€βΊsend_remove() β
β update() ββββββΌβββββββ€βΊsend_update() ββββββ β
β β² β β βΌ β
ββββ¬βββββββββββββ ββββΌβsignal(inventory_updated) β
β β β β
ββββββββββββββββββ βββββββββββββββββββββββββββββ
The problem is clear when updating an inventory, and listening for an inventory update
After - layered architecture
Iβve added a βNet Syncβ module as a broker layer between the actual βNetworkβ comms layer.
Each layer should only interact with immediately adjacent layers.
If the player is online (in a real game)
If the player is offline (local dev/debug and game design)
The βNet Syncβ layer skips talking to network socket and echoes the same data from the send()
signals
The public interface for Inventory
is βsafeβ to use and the code can trust that recv()
signals will be emitted in both online and offline modes
Get Camp Fire Craft
Camp Fire Craft
Multiplayer survival game where teams compete to earn badges while camping
Status | In development |
Authors | GomaGames, kellishouts |
Genre | Survival |
Tags | Crafting, Godot, Multiplayer, Team-Based, Top-Down |
More posts
- Synchronizing Multiplayer Game State - βΊοΈ πββοΈMar 19, 2022
- Multiplayer LobbyMar 06, 2022
- π build-220226bFeb 27, 2022
- SinglePlayer Level Design - Process time lapse videoFeb 24, 2022
- Game Title and Sketches for brandingFeb 20, 2022
- π Scouts Handbook UI πFeb 19, 2022
- π¦ βΊοΈ Foxes can destroy tents βΊοΈ π¦Feb 19, 2022
- π¨π¦ New Animations π¦π¨Feb 19, 2022
- Updated Animations πͺ βοΈFeb 19, 2022
Leave a comment
Log in with itch.io to leave a comment.