Comments (4)
Hi! thanks for looking into GGRS!
Inspired by GGPO, GGRS is intended to be used to synchronise state for short p2p sessions (think a single match of a fighting game) between a small amount of players (think 2-4). The use case is quite specific, but the strong assumptions allow for strong results (in this case, this is "playing online with no added input latency").
From the few pointers you have given me, it seems like you should probably look into other options, as well. I recommend a server/host-based architecture that allows both for flexible drop-in and -out of players and maybe an event-driven synchronisation of state to cater your inventory/crafting needs.
I'll answer each point separately, hope that will shed some light on your issue ;)
Inputs
how would a 3d game even represent mouse movement (or do we treat the view vector itself as an input?)
you could encode the mouse dx and dy with fixed precision into a u32 or similar.
what about games with complex context dependant ui (minecraft crafting table, lets say) . I can maybe imagine creating an input struct with all possible actions in the game a player can take. But this breaks alot of the modularity of ecs, is there a better way?
I think that games with menu and inventory are probably better off with event-based networking. Deriving the outcomes of menu interaction from dx/dy alone seems very unnecessary.
the input struct seems to require Pod, which I have a hard time wrapping my head around the implications of.
It's basically a more modular way of saying "this can be represented through a fixed-size sequence of bits"
Desync
Intuition warns me this might become unmanageable in a more complex game.
The assumption that all state can be derived from inputs alone is quite strong, but it leads to a very efficient networking model. Making sure the state is actually deterministic is quite hard in practice.
Ggrs has tools for desync detection, but none for recovery. I do not understand the model well enough to know whether an out of band system for resyncing is even possible (would ggrs play nice).
There currently is no way to sync state other than through inputs. Desync detection is intended for debugging only. A feature like this could potentially be added, but I am very unsure this is actually a good thing for the purposes of this library.
Drop-In players
how hard would it be to get ggrs to play nice with players that spawn in as they load.
currently not possible, but potentially doable (by adding the functionality to GGRS). In usecases like this, I usually suggest a server-based architecture to handle flexible drop-in and drop-out at any time.
how would a game using ggrs handle NPCs spawned via RNG
All RNG has to be fixed through seeding in order to assure that a pseudo-randomly generated number is exactly the same across all clients.
from bevy_ggrs.
There is a gotcha too.
If you are using a SceneBundle (to use a gltf model for example), the SceneBundle will have child entities that get spawned automatically that will not be rolled back.
A workaround is to keep the player components simple, and have a separate non-rollback entity with the SceneBundle setting it's Transform to the same Transform as the player.
Rollbacks with parent/child entities leads to the Parent component and Children component pointing to entities that do not exist. So rollback of parent/child entity stuff needs to be either avoided, or the user need to reimplement their own parent/child stuff using Stable IDs rather than the Entity IDs to link them up.
Here is a little demo:
- demo: https://clinuxrulz.github.io/flying-shooter/
- source: https://github.com/clinuxrulz/flying-shooter
I use a FollowPlayer
component to get the SceneBundle
to follow the player on a separate entity.
from bevy_ggrs.
On the topic of a 3D example: I am sure we could enrich the repository by providing one. Thanks for the recommendation!
from bevy_ggrs.
closing this for now. feel free to reach out if further questions come up.
from bevy_ggrs.
Related Issues (20)
- [Question] How to sync elapsed time since startup among peers? HOT 4
- Update entity IDs in Children/Parent components on rollback. HOT 2
- Update to Bevy 0.13
- Document idiomatic way to sort rollback related queries
- Synctest session doesn't detect all desyncs that it could/should
- Adding players after p2p session already started HOT 3
- Support synchronizing parts of world state, since Rust isn't deterministic. HOT 15
- Potential Scalability Refactor HOT 6
- Sessions `.with_desync_detection(DesyncDetection::On)` always reports false positives HOT 1
- Integration Tests incorrect HOT 2
- More idiomatic component/resource checksums for float types?
- Adding non-rollbacked children to rollbacked entities break the hierarchy HOT 1
- Desync detection appears to compare the checksum of predicted frames to confirmed frames HOT 8
- Sprite Component doesn't get respawned after rollback HOT 5
- panic: `Rollback requested was not created using AddRollbackCommand!`
- When rollbacks happen across entity spawning, desyncs are reported HOT 1
- Despawned entities are not restored HOT 2
- Convenient way to end a session HOT 5
- Checksums are not portable HOT 5
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 bevy_ggrs.