Skip to content

Commit

Permalink
NetworkTransform: explain send interval and make it obvious that sync…
Browse files Browse the repository at this point in the history
…Interval isn't used
  • Loading branch information
vis2k committed Oct 22, 2022
1 parent 38d94f3 commit 28fe97d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public abstract class NetworkTransformBase : NetworkBehaviour
// make sure to call this when inheriting too!
protected virtual void Awake() {}

protected virtual void OnValidate()
{
// Update uses NetworkServer.sendInterval to be on the same send
// rate as time interpolation. make it obvious that syncInterval
// isn't respected.
syncInterval = NetworkServer.sendInterval;
}

// snapshot functions //////////////////////////////////////////////////
// construct a snapshot of the current state
// => internal for testing
Expand Down Expand Up @@ -300,7 +308,7 @@ void UpdateServer()
// authoritative movement done by the host will have to be broadcasted
// here by checking IsClientWithAuthority.
// TODO send same time that NetworkServer sends time snapshot?
if (NetworkTime.localTime >= lastServerSendTime + NetworkServer.sendInterval &&
if (NetworkTime.localTime >= lastServerSendTime + NetworkServer.sendInterval && // same interval as time interpolation!
(!clientAuthority || IsClientWithAuthority))
{
// send snapshot without timestamp.
Expand Down Expand Up @@ -395,7 +403,7 @@ void UpdateClient()
// DO NOT send nulls if not changed 'since last send' either. we
// send unreliable and don't know which 'last send' the other end
// received successfully.
if (NetworkTime.localTime >= lastClientSendTime + NetworkServer.sendInterval)
if (NetworkTime.localTime >= lastClientSendTime + NetworkServer.sendInterval) // same interval as time interpolation!
{
// send snapshot without timestamp.
// receiver gets it from batch timestamp to save bandwidth.
Expand Down

0 comments on commit 28fe97d

Please sign in to comment.