NetworPlayerState struct (Experimental) #3955
Open
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.
Network Player State Struct
This struct is intended to transfer the most common states used for desync detection and reconciliation as efficiently as possible
( see diagram ) with addition of 3 functions that meant to simplify the process.
1. Ability to pass
defaults
in the constructor.This is meant to allow easy cloning of the struct while retaining the ability to change any one of the memebers
2. Ability to compare and extract changes.
It is important to send as little information as possible to reduce the network traffic hence we really only want to send the changes ( for example if rotation remained the same we dont send it but we do send the new position for comparison )
3. Ability to duplicate with overrides
This is crucial when working with only changes and is meant to allow for cloning previous state with the received changes in a compact manner.
This is particularly usefull to reduce the code size when sending the changes over network
Fields:
It is required before sending as it is a part of the header
no change
andno parent
please usenew NetworkPlayerState().IsParentSet
note: If parent is sent It is the developer decision if to send relative values or absolute ones
Usage example:
Byte Structure Diagram
Summary i guess...
This is 2 of 2 structs i want to introduce to allow for a simple and coherent exchange of inputs and states between server and client.
When combined the message with both NetworkPlayerInputs and NetworkPlayerState:
The ideal scenario is to send only the inputs on change
and every Nth tick to send inputs with the state attached for desync detection