Optimized position broadcasting and more network debugger info. #2014
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, Nitrox broadcasts every simulated entity's position every 0.25 seconds. This gives the appearance of fish synchronization but causes significant load - especially for non-LAN players.
This PR changes the mechanics behind movement simulation for most entities. Things that have a SwimBehavior or WalkBehavior (that internally use a SplineFollow) will broadcast changes only when their destination changes. This provides more fluid behavior and significantly reduces packet volume.
One thing to note is that some entities will still need the previous behavior. For example, dropping an item that floats down to the bottom. In this case, we can look towards future optimizations to dedupe packets when little movement actually occurred or perform a similar custom spline behavior.
Benchmark results over 12 min:
Old System: 6669 packets (48.6MB)
New System: 6593 packets (8.8MB)
Screenshot (with the built in SimulateLatency enabled in LiteNetLib):
Also included in this PR is an update to add byte aggregation to the network debugger. See below: