Comments (5)
It's also worth considering the option of bandwidth-limited syncing, like Halo Reach uses. Instead of always syncing every entity, collect all the entities in need of syncing, sort them by some priority value (calculated, for instance, by a priority accumulator + closeness to the camera * some importance value), then start serialising them until you run reach some specified size. For any entities that got serialised, reset the accumulator to 0, for any others, increment the accumulator.
This risks increased mispredictions because dependant entities may be synchronised out of sync and thus the predictions may not always be accurate, but it allows very precise control of bandwidth and is still always moving towards "eventually accurate".
I have no idea if the precise bandwidth control is worth the extra complexity and slightly dodgy predictions but I've always liked the idea. I implemented it in my Godot networking system but I never got further than two capsules moving around so I never got as far as testing how it behaves in a real game.
from lightyear.
Bandwidth-limiting syncing is already implemented :)
See this section of the book for more information: https://cbournhonesque.github.io/lightyear/book/concepts/advanced_replication/bandwidth_management.html#prioritizing-replication-groups
It's pretty much exactly what you described:
- you can set a maximum bandwidth
- every ReplicationGroup or Message can get assigned a Priority score (by default 1.0) which gets accumulated
- we serialize groups in order of priority, until the bandwidth limit is reached
Normally it shouldn't increase mispredictions too much, because entities within a ReplicationGroup
are always replicated together.
Here is an example showcasing it: https://github.com/cBournhonesque/lightyear/tree/main/examples/priority
I was wondering if on top of that I could update the replication_rate for a given ReplicationGroup, primarily as a way to save on CPU usage. For example for some unimportant background element the replication rate could be 1Hz instead of 10Hz, and the entity wouldn't get included in the priority accumulation most of the time.
from lightyear.
Aha! Well that'll teach me to comment before I finish reading the docs 🤦♂️
from lightyear.
I'd also like to express my interest in this, or some variant of it.
I have a game world time (i.e. time of day) that I'd like to synchronise between the server and the client, and that time ticks at a regular rate (i.e. a game-minute every real-second).
I'd like to periodically synchronise the client's time with the server-authoritative time to make sure it doesn't drift too much, and to allow for the server changing the time. I think this would just be running the same system on both the server and the client with prediction, but I'd like to throttle how frequently that update occurs.
Is this currently possible, or will it depend on this issue? Additionally, should I store this in a resource or an entity?
from lightyear.
I think this is already possible; you could either:
- send a
TimeUpdate
message from server->client at a regular interval, and use that to update a resource on the client - have 2 Time resources on the server. One is internal, and gets updated regularly. The other is only for syncing to clients (so with server->client replication enabled), and gets updated infrequently via a run_condition. (probably one of these: https://docs.rs/bevy/latest/bevy/time/common_conditions/index.html)
I think this issue is more focused on saving CPU usage by skipping some entities in the replication systems (for which we know we only want infrequent updates)
from lightyear.
Related Issues (20)
- Maybe parallelize component-specific systems with https://github.com/bevyengine/bevy/pull/13123
- Enable bi-directional resource replicaiton
- Confusion over `Netcode` authentication / `client_id` HOT 10
- Unfinished doc comment in simple_box example HOT 1
- Zstd fails to build in wasm (on my mac m1)
- Make client responsible for initiating prediction/interpolation
- Server-spawned client replication HOT 11
- Log spam when a connection is terminated HOT 14
- Panic in encode_packet HOT 5
- Interest management example broken
- Be able to update the `Replicate` component at runtime HOT 3
- Adding visual interpolation on a component seems to trigger a lot of rollbacks
- Let users specify their own comparison function for rollback check
- Allow server to validate packets that need to be reboadcasted to other clients
- Only apply replication updates if the new value is different from the existing value HOT 5
- Fix inputs handling in FixedUpdate
- Maybe we can remove the `BufferInputs` system set HOT 1
- Bullet pre-spawn error since replication refactor
- Publish the example `common` crate. HOT 1
- Provide a more expressive way to replicate only a subset of components of an entity HOT 2
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 lightyear.