Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized position broadcasting and more network debugger info. #2014

Merged
merged 2 commits into from
Apr 9, 2023

Conversation

Sunrunner37
Copy link
Member

@Sunrunner37 Sunrunner37 commented Apr 3, 2023

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):

image

Also included in this PR is an update to add byte aggregation to the network debugger. See below:

image

NitroxClient/MonoBehaviours/RemotelyControlled.cs Outdated Show resolved Hide resolved
NitroxClient/MonoBehaviours/RemotelyControlled.cs Outdated Show resolved Hide resolved
NitroxClient/MonoBehaviours/RemotelyControlled.cs Outdated Show resolved Hide resolved
NitroxClient/Debuggers/NetworkDebugger.cs Outdated Show resolved Hide resolved
NitroxClient/Communication/PacketReceiver.cs Outdated Show resolved Hide resolved
@Sunrunner37
Copy link
Member Author

Applied the requested changes.

Copy link
Collaborator

@Measurity Measurity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes fish jump around even on LAN. But for the most part it's stable.

@Sunrunner37 Sunrunner37 merged commit 31245f5 into SubnauticaNitrox:master Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants