Comments (3)
Sure! Here are a few pointers:
In FlatBuffers, your whole payload needs to be all created at once. That means you cannot include player-only data in the game-wide state update messages that is the same for for everyone: that would require regenerating data meant for everyone for each player, and would absolutely kill performance. What you'll want to do is therefore create a new separate message type to update player-only data.
To create a new message type, you'll need to:
- Go in
protocol/ServerMessages
and write a FlatBuffer definition of your payload. A table with a Variable should be good enough for now. - In
protocol/ServerMessages/ServerMessage.fbs
, import your new message file and add it to theServerMessagesContent
union. - In
code/server/ServerMessagesSender.ts
, add a function similar to the previous ones, that creates a FlatBuffer ServerMessage using aBuilder
, and sends it via the adapter. - In
code/client/ClientLifetimeFunctions.ts
, add to the switch statement for processing incoming messages a new case fr your new message type.
Once that is done, you'll have your message implemented. All that you will have left to do is:
On the server:
- Store a
SyncedVariable
for each player inCode/PlayerContext.ts
- Make the switching of player context replace the scene variable
PlayerState
with the storedSyncedVariable
- Send a diff of their own variables to each player in the server lifetime function, just after the shared game state
On the client:
- In the message handler for your new message type, deserialize the diffs sent in that message into the
PlayerState
scene variable
There should be no need (for now) to support full snapshots, since a player variable is empty when the player connects (as it is only for that player :p), so there is no previous state the client should be aware of before applying the diffs from the server.
I'll be leaving this to you then, don't hesitate to ask if you have any questions! If that is too difficult after all, please say so so someone else may give the issue a try ;)
I also recommend reading the flat buffers doc a quick read before you get started:
https://google.github.io/flatbuffers/flatbuffers_guide_writing_schema.html
https://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html (Click on "TypeScript" to get accurate code snippets)
from thnk.
Can I try to work on it ?
from thnk.
Since I haven't heard back, I'll assume it didn't work out. This is a pretty crucial feature so I'll be working on it myself now.
from thnk.
Related Issues (20)
- WebSockets adapter HOT 1
- Server replicas system
- Saving system
- Split-Screen adapter
- Authentication support
- Ping expression
- Geckos.io Adapter
- Internal unreliability compensation
- Add QoS to THNK messages
- Context isolation
- Snapshot system
- Disconnection features
- Don't understand how to make work the ยซ Quick start ยป Scene in the THNK example HOT 1
- Infinite Windows Opening With Local Server HOT 4
- Connection manager
- Game wont start when p2p adapter is used HOT 1
- THNK local or P2P HOT 2
- [Bug] Creating object on UI layer HOT 1
- [Bug] Bitmap text is not Synced HOT 1
- Cant leave the server after hosting one HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thnk.