My Project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Properties | List of all members
SmoothSync Class Reference
Inheritance diagram for SmoothSync:
StandardPump Teal.PumpObject

Public Types

enum  SyncMode {
  XYZ , XY , XZ , YZ ,
  X , Y , Z , NONE
}
 
enum  ExtrapolationMode { None , Limited , Unlimited }
 Extrapolation type. More...
 
enum  WhenToUpdateTransform { Update , FixedUpdate }
 Info to know where to update the Transform.
 

Public Member Functions

delegate bool validateStateDelegate (SmoothState receivedState, SmoothState latestVerifiedState)
 Validation delegate.
 
void ForceState (Vector2 pos, Vector3 vel)
 
Vector3 getPosition ()
 Get position of object based on if child or not.
 
Quaternion getRotation ()
 Get rotation of object based on if child or not.
 
Vector3 getScale ()
 Get scale of object.
 
void setPosition (Vector3 position, bool isTeleporting)
 Set position of object based on if child or not.
 
void setRotation (Quaternion rotation, bool isTeleporting)
 Set rotation of object based on if child or not.
 
void setScale (Vector3 scale, bool isTeleporting)
 Set scale of object.
 
void addState (SmoothState state)
 Add an incoming state to the stateBuffer on non-owned objects.
 
void stopLerping ()
 Stop updating the States of non-owned objects so that the object can be teleported.
 
void ForceStateSendNext ()
 Forces the State to be sent on owned objects the next time it goes through OnPhotonSerializeView().
 
bool shouldSendPosition ()
 Check if position has changed enough.
 
bool shouldSendRotation ()
 Check if rotation has changed enough.
 
bool shouldSendScale ()
 Check if scale has changed enough.
 
bool shouldSendVelocity ()
 Check if velocity has changed enough.
 
bool shouldSendAngularVelocity ()
 Check if angular velocity has changed enough.
 
override bool SendPump (BitPacker packer)
 
override void ReceivePump (BitPacker packer)
 
- Public Member Functions inherited from StandardPump
override bool UpdateIsMine ()
 
- Public Member Functions inherited from Teal.PumpObject
virtual bool UpdateIsMine ()
 
bool IsMine ()
 
virtual bool SendPump (BitPacker packer)
 
virtual void ReceivePump (BitPacker packer)
 
virtual bool SendPumps (BitPacker packer)
 
virtual bool ReceivePumps (BitPacker packer)
 
virtual void DebugLog ()
 
void SetOwner (ushort id)
 

Static Public Member Functions

static bool validateState (SmoothState latestReceivedState, SmoothState latestValidatedState)
 Validation method.
 

Public Attributes

Transform debug
 
bool resetRigidBody = false
 Reset to 0 so that velocity doesn't affect movement since we set position every frame.
 
Vector2 velocityBeforeReset
 
float angularVelocityBeforeReset
 
bool sendPing = false
 
ExtrapolationMode extrapolationMode = ExtrapolationMode.Limited
 The amount of extrapolation used.
 
bool useExtrapolationTimeLimit = true
 Whether or not you want to use the extrapolationTimeLimit.
 
float extrapolationTimeLimit = 5.0f
 How much time into the future a non-owned object is allowed to extrapolate.
 
bool useExtrapolationDistanceLimit = false
 Whether or not you want to use the extrapolationDistanceLimit.
 
float extrapolationDistanceLimit = 20.0f
 How much distance into the future a non-owned object is allowed to extrapolate.
 
float sendPositionThreshold = 0.0f
 The position won't send unless it changed this much.
 
float sendRotationThreshold = 0.0f
 The rotation won't send unless it changed this much.
 
float sendScaleThreshold = 0.0f
 The scale won't send unless it changed this much.
 
float sendVelocityThreshold = 0.0f
 The velocity won't send unless it changed this much.
 
float sendAngularVelocityThreshold = 0.0f
 The angular velocity won't send unless it changed this much.
 
float receivedPositionThreshold = 0.0f
 The position won't be set on non-owned objects unless it changed this much.
 
float receivedRotationThreshold = 0.0f
 The rotation won't be set on non-owned objects unless it changed this much.
 
float snapPositionThreshold = 0
 If a synced object's position is more than snapPositionThreshold units from the target position, it will jump to the target position immediately instead of lerping.
 
float snapRotationThreshold = 0
 If a synced object's rotation is more than snapRotationThreshold from the target rotation, it will jump to the target rotation immediately instead of lerping.
 
float snapScaleThreshold = 0
 If a synced object's scale is more than snapScaleThreshold units from the target scale, it will jump to the target scale immediately instead of lerping.
 
float positionLerpSpeed = .85f
 How fast to lerp the position to the target state. 0 is never, 1 is instant.
 
float rotationLerpSpeed = .85f
 How fast to lerp the rotation to the target state. 0 is never, 1 is instant..
 
float scaleLerpSpeed = .85f
 How fast to lerp the scale to the target state. 0 is never, 1 is instant.
 
float timeCorrectionSpeed = .1f
 How fast to change the estimated owner time of non-owned objects. 0 is never, 5 is basically instant.
 
float snapTimeThreshold = 3.0f
 The estimated owner time of non-owned objects will change instantly if it is off by this amount.
 
SyncMode syncPosition = SyncMode.XYZ
 Position sync mode.
 
SyncMode syncRotation = SyncMode.XYZ
 Rotation sync mode.
 
SyncMode syncScale = SyncMode.XYZ
 Scale sync mode.
 
SyncMode syncVelocity = SyncMode.XYZ
 Velocity sync mode.
 
SyncMode syncAngularVelocity = SyncMode.XYZ
 Angular velocity sync mode.
 
bool isPositionCompressed = false
 Compress position floats when sending over the network.
 
bool isRotationCompressed = false
 Compress rotation floats when sending over the network.
 
bool isScaleCompressed = false
 Compress scale floats when sending over the network.
 
bool isVelocityCompressed = false
 Compress velocity floats when sending over the network.
 
bool isAngularVelocityCompressed = false
 Compress angular velocity floats when sending over the network.
 
WhenToUpdateTransform whenToUpdateTransform = WhenToUpdateTransform.Update
 Where the object's Transform is updated on non-owners.
 
GameObject childObjectToSync
 Child object to sync.
 
bool hasChildObject = false
 Does this game object have a child object to sync?
 
validateStateDelegate validateStateMethod = validateState
 Validation method variable.
 
bool setVelocityInsteadOfPositionOnNonOwners = false
 Set velocity on non-owners instead of the position.
 
bool useLocalTransformOnly = false
 Useful for VR applications that always have objects in local space.
 
float maxPositionDifferenceForVelocitySyncing = 10
 An exponential scale used to determine how high the velocity should be set.
 
SmoothState[] stateBuffer
 Non-owners keep a list of recent States received over the network for interpolating.
 
int stateCount
 The number of States in the stateBuffer.
 
Rigidbody rb
 Store a reference to the rigidbody so that we only have to call GetComponent() once.
 
bool hasRigidbody = false
 Does this game object have a Rigidbody component?
 
Rigidbody2D rb2D
 Store a reference to the 2D rigidbody so that we only have to call GetComponent() once.
 
bool hasRigidbody2D = false
 Does this game object have a Rigidbody2D component?
 
float lastTimeStateWasSent
 Last time owner sent a State.
 
Vector3 lastPositionWhenStateWasSent
 Position owner was at when the last position State was sent.
 
Quaternion lastRotationWhenStateWasSent = Quaternion.identity
 Rotation owner was at when the last rotation State was sent.
 
Vector3 lastScaleWhenStateWasSent
 Scale owner was at when the last scale State was sent.
 
Vector3 lastVelocityWhenStateWasSent
 Velocity owner was at when the last velocity State was sent.
 
Vector3 lastAngularVelocityWhenStateWasSent
 Angular velocity owner was at when the last angular velociy State was sent.
 
GameObject realObjectToSync
 Gets assigned to the real object to sync. Either this object or a child object.
 
int syncIndex = 0
 Index to know which object to sync.
 
SmoothSync[] childObjectSmoothSyncs = new SmoothSync[0]
 Reference to child objects so you can compare to syncIndex.
 
bool forceStateSend = false
 Gets set to true in order to force the State to be sent next OnSerializePhotonView() on owners.
 
bool sendAtPositionalRestMessage = false
 Gets set to true when position is the same for two frames in order to tell non-owners to stop extrapolating position.
 
bool sendAtRotationalRestMessage = false
 Gets set to true when rotation is the same for two frames in order to tell non-owners to stop extrapolating rotation.
 
bool sendPosition
 Variable we set at the beginning of Update so we only need to do the checks once a frame.
 
bool sendRotation
 Variable we set at the beginning of Update so we only need to do the checks once a frame.
 
bool sendScale
 Variable we set at the beginning of Update so we only need to do the checks once a frame.
 
bool sendVelocity
 Variable we set at the beginning of Update so we only need to do the checks once a frame.
 
bool sendAngularVelocity
 Variable we set at the beginning of Update so we only need to do the checks once a frame.
 
Vector3 latestReceivedVelocity
 The latest received velocity. Used for extrapolation.
 
Vector3 latestReceivedAngularVelocity
 The latest received angular velocity. Used for extrapolation.
 
bool extrapolatedLastFrame = false
 Whether or not the object used extrapolation last frame. Used to reset extrapolation variables.
 
int receivedStatesCounter
 If this number is less than SendRate, force full time adjustment. Used when first entering a game.
 
- Public Attributes inherited from StandardPump
StandardObject standard
 
Controls controls
 
Item item
 
- Public Attributes inherited from Teal.PumpObject
bool isMine
 
ushort ownerId
 
float timeSinceCreated
 
bool relay
 
PumpObject[] pumpObjects
 

Static Public Attributes

static bool UseSmoothSync = false
 
static bool Extrapolate = false
 
static int SendRate = 50
 
static float interpolationBackTime = .06f
 How much time in the past non-owned objects should be.
 

Protected Member Functions

override void Awake ()
 Cache references to components.
 
- Protected Member Functions inherited from StandardPump
override void Awake ()
 
- Protected Member Functions inherited from Teal.PumpObject
void Initialize ()
 
virtual void Awake ()
 
virtual void Start ()
 
virtual void OnDestroy ()
 
virtual bool IsLocalAuthority ()
 
int ReadPingCheck (BitPacker packer, bool isLocal)
 
void WritePingCheck (BitPacker packer, bool isLocal)
 

Properties

bool isSyncingXPosition [get]
 Determine if should be syncing.
 
bool isSyncingYPosition [get]
 Determine if should be syncing.
 
bool isSyncingZPosition [get]
 Determine if should be syncing.
 
bool isSyncingXRotation [get]
 Determine if should be syncing.
 
bool isSyncingYRotation [get]
 Determine if should be syncing.
 
bool isSyncingZRotation [get]
 Determine if should be syncing.
 
bool isSyncingXScale [get]
 Determine if should be syncing.
 
bool isSyncingYScale [get]
 Determine if should be syncing.
 
bool isSyncingZScale [get]
 Determine if should be syncing.
 
bool isSyncingXVelocity [get]
 Determine if should be syncing.
 
bool isSyncingYVelocity [get]
 Determine if should be syncing.
 
bool isSyncingZVelocity [get]
 Determine if should be syncing.
 
bool isSyncingXAngularVelocity [get]
 Determine if should be syncing.
 
bool isSyncingYAngularVelocity [get]
 Determine if should be syncing.
 
bool isSyncingZAngularVelocity [get]
 Determine if should be syncing.
 
float approximateNetworkTimeOnOwner [get, set]
 The current estimated time on the owner.
 
- Properties inherited from Teal.PumpObject
NetworkObject net [get]
 

Additional Inherited Members

- Protected Attributes inherited from Teal.PumpObject
Dictionary< byte, long > stateTimes = new Dictionary<byte, long>()
 
byte state
 
byte lastGotState
 

Member Enumeration Documentation

◆ ExtrapolationMode

Extrapolation type.

Extrapolation is going into the unknown based on information we had in the past. Generally, you'll want extrapolation to help fill in missing information during latency spikes. None - Use no extrapolation. Limited - Use the settings for extrapolation limits. Unlimited - Allow extrapolation forever. Must be syncing velocity in order to utilize extrapolation.

Member Function Documentation

◆ Awake()

override void SmoothSync.Awake ( )
inlineprotectedvirtual

Cache references to components.

Reimplemented from Teal.PumpObject.

◆ ForceStateSendNext()

void SmoothSync.ForceStateSendNext ( )
inline

Forces the State to be sent on owned objects the next time it goes through OnPhotonSerializeView().

The state will get sent next OnPhotonSerializeView() regardless of all limitations.

◆ ReceivePump()

override void SmoothSync.ReceivePump ( BitPacker  packer)
inlinevirtual

Reimplemented from Teal.PumpObject.

◆ SendPump()

override bool SmoothSync.SendPump ( BitPacker  packer)
inlinevirtual

Reimplemented from Teal.PumpObject.

◆ shouldSendAngularVelocity()

bool SmoothSync.shouldSendAngularVelocity ( )
inline

Check if angular velocity has changed enough.

If sendAngularVelocityThreshold is 0, returns true if the current angular velocity is different from the latest sent angular velocity. If sendAngularVelocityThreshold is greater than 0, returns true if difference between angular velocity and latest sent angular velocity is greater than the angular velocity threshold.

◆ shouldSendPosition()

bool SmoothSync.shouldSendPosition ( )
inline

Check if position has changed enough.

If sendPositionThreshold is 0, returns true if the current position is different than the latest sent position. If sendPositionThreshold is greater than 0, returns true if distance between position and latest sent position is greater than the sendPositionThreshold.

◆ shouldSendRotation()

bool SmoothSync.shouldSendRotation ( )
inline

Check if rotation has changed enough.

If sendRotationThreshold is 0, returns true if the current rotation is different from the latest sent rotation. If sendRotationThreshold is greater than 0, returns true if difference (angle) between rotation and latest sent rotation is greater than the sendRotationThreshold.

◆ shouldSendScale()

bool SmoothSync.shouldSendScale ( )
inline

Check if scale has changed enough.

If sendScaleThreshold is 0, returns true if the current scale is different than the latest sent scale. If sendScaleThreshold is greater than 0, returns true if the difference between scale and latest sent scale is greater than the sendScaleThreshold.

◆ shouldSendVelocity()

bool SmoothSync.shouldSendVelocity ( )
inline

Check if velocity has changed enough.

If sendVelocityThreshold is 0, returns true if the current velocity is different from the latest sent velocity. If sendVelocityThreshold is greater than 0, returns true if difference between velocity and latest sent velocity is greater than the velocity threshold.

◆ validateState()

static bool SmoothSync.validateState ( SmoothState  latestReceivedState,
SmoothState  latestValidatedState 
)
inlinestatic

Validation method.

The default validation method that allows all States. Your custom validation method must match the parameter types of this method. Return false to deny the State. The State will not be added locally on the server and it will not be sent out to other clients. Return true to accept the State. The State will be added locally on the server and will be sent out to other clients.

◆ validateStateDelegate()

delegate bool SmoothSync.validateStateDelegate ( SmoothState  receivedState,
SmoothState  latestVerifiedState 
)

Validation delegate.

To tie in your own validation method, check the SmoothSyncExample scene and SmoothSyncExamplePlayerController.cs on how to use the validation delegate.

Smooth Sync will call this on the server on every incoming State message. By default it allows every received State but you can set the validateStateMethod to a custom one in order to validate that the clients aren't modifying their owned objects beyond the game's intended limits.

Member Data Documentation

◆ childObjectToSync

GameObject SmoothSync.childObjectToSync

Child object to sync.

Leave blank if you want to sync this object. In order to sync a child object, you must add two instances of SmoothSync to the parent. Set childObjectToSync on one of them to point to the child you want to sync and leave it blank on the other to sync the parent. You cannot sync children without syncing the parent.

◆ extrapolationDistanceLimit

float SmoothSync.extrapolationDistanceLimit = 20.0f

How much distance into the future a non-owned object is allowed to extrapolate.

Extrapolating too far tends to cause erratic and non-realistic movement, but a little bit of extrapolation is better than none because it keeps things working semi-right during latency spikes.

Must be syncing velocity in order to utilize extrapolation.

Measured in distance units.

◆ extrapolationMode

ExtrapolationMode SmoothSync.extrapolationMode = ExtrapolationMode.Limited

The amount of extrapolation used.

Extrapolation is going into the unknown based on information we had in the past. Generally, you'll want extrapolation to help fill in missing information during lag spikes. None - Use no extrapolation. Limited - Use the settings for extrapolation limits. Unlimited - Allow extrapolation forever.

◆ extrapolationTimeLimit

float SmoothSync.extrapolationTimeLimit = 5.0f

How much time into the future a non-owned object is allowed to extrapolate.

Extrapolating too far tends to cause erratic and non-realistic movement, but a little bit of extrapolation is better than none because it keeps things working semi-right during latency spikes.

Must be syncing velocity in order to utilize extrapolation.

Measured in seconds.

◆ hasChildObject

bool SmoothSync.hasChildObject = false

Does this game object have a child object to sync?

Is much less resource intensive to check a boolean than if a Gameobject exists.

◆ hasRigidbody

bool SmoothSync.hasRigidbody = false

Does this game object have a Rigidbody component?

Is much less resource intensive to check a boolean than if a component exists.

◆ hasRigidbody2D

bool SmoothSync.hasRigidbody2D = false

Does this game object have a Rigidbody2D component?

Is much less resource intensive to check a boolean than if a component exists.

◆ interpolationBackTime

float SmoothSync.interpolationBackTime = .06f
static

How much time in the past non-owned objects should be.

interpolationBackTime is the amount of time in the past the object will be on non-owners. This is so if you hit a latency spike, you still have a buffer of the interpolation back time of known States before you start extrapolating into the unknown.

Essentially, for everyone who has ping less than the interpolationBackTime, the object will appear in the same place on all screens.

Increasing this will make interpolation more likely to be used, which means the synced position will be more likely to be an actual position that the owner was at.

Decreasing this will make extrapolation more likely to be used, this will increase responsiveness, but with any latency spikes that last longer than the interpolationBackTime, the position will be less correct to where the player was actually at.

Keep above 1/SendRate to attempt to always interpolate.

Measured in seconds.

◆ isAngularVelocityCompressed

bool SmoothSync.isAngularVelocityCompressed = false

Compress angular velocity floats when sending over the network.

Convert angular velocity floats sent over the network to Halfs, which use half as much bandwidth but are also half as precise.

◆ isPositionCompressed

bool SmoothSync.isPositionCompressed = false

Compress position floats when sending over the network.

Convert position floats sent over the network to Halfs, which use half as much bandwidth but are also half as precise. It'll start becoming noticeably "off" over ~600.

◆ isRotationCompressed

bool SmoothSync.isRotationCompressed = false

Compress rotation floats when sending over the network.

Convert rotation floats sent over the network to Halfs, which use half as much bandwidth but are also half as precise.

◆ isScaleCompressed

bool SmoothSync.isScaleCompressed = false

Compress scale floats when sending over the network.

Convert scale floats sent over the network to Halfs, which use half as much bandwidth but are also half as precise.

◆ isVelocityCompressed

bool SmoothSync.isVelocityCompressed = false

Compress velocity floats when sending over the network.

Convert velocity floats sent over the network to Halfs, which use half as much bandwidth but are also half as precise.

◆ maxPositionDifferenceForVelocitySyncing

float SmoothSync.maxPositionDifferenceForVelocitySyncing = 10

An exponential scale used to determine how high the velocity should be set.

If the difference between where it should be and where it is hits this, then it will automatically jump to location. Is on an exponential scale normally.

◆ positionLerpSpeed

float SmoothSync.positionLerpSpeed = .85f

How fast to lerp the position to the target state. 0 is never, 1 is instant.

Lower values mean smoother but maybe sluggish movement. Higher values mean more responsive but maybe jerky or stuttery movement.

◆ rb

Rigidbody SmoothSync.rb

Store a reference to the rigidbody so that we only have to call GetComponent() once.

Will automatically use Rigidbody or Rigidbody2D depending on what is on the game object.

◆ receivedPositionThreshold

float SmoothSync.receivedPositionThreshold = 0.0f

The position won't be set on non-owned objects unless it changed this much.

Set to 0 to always update the position of non-owned objects if it has changed, and to use one less Vector3.Distance() check per frame if you also have snapPositionThreshold at 0. If greater than 0, a synced object's position is only updated if it is off from the target position by more than the threshold. Usually keep this at 0 or really low, at higher numbers it's useful if you are extrapolating into the future and want to stop instantly and not have it backtrack to where it currently is on the owner. Measured in distance units.

◆ receivedRotationThreshold

float SmoothSync.receivedRotationThreshold = 0.0f

The rotation won't be set on non-owned objects unless it changed this much.

Set to 0 to always update the rotation of non-owned objects if it has changed, and to use one less Quaternion.Angle() check per frame if you also have snapRotationThreshold at 0. If greater than 0, a synced object's rotation is only updated if it is off from the target rotation by more than the threshold. Usually keep this at 0 or really low, at higher numbers it's useful if you are extrapolating into the future and want to stop instantly and not have it backtrack to where it currently is on the owner. Measured in degrees.

◆ rotationLerpSpeed

float SmoothSync.rotationLerpSpeed = .85f

How fast to lerp the rotation to the target state. 0 is never, 1 is instant..

Lower values mean smoother but maybe sluggish movement. Higher values mean more responsive but maybe jerky or stuttery movement.

◆ scaleLerpSpeed

float SmoothSync.scaleLerpSpeed = .85f

How fast to lerp the scale to the target state. 0 is never, 1 is instant.

Lower values mean smoother but maybe sluggish movement. Higher values mean more responsive but maybe jerky or stuttery movement.

◆ sendAngularVelocityThreshold

float SmoothSync.sendAngularVelocityThreshold = 0.0f

The angular velocity won't send unless it changed this much.

Set to 0 to always send the angular velocity of owned objects if it has changed since the last sent angular velocity, and for a hardware performance increase, but at the cost of network usage. If greater than 0, a synced object's angular velocity is only sent if its angular velocity is off from the last sent angular velocity by more than the threshold. Measured in degrees per second.

◆ sendPositionThreshold

float SmoothSync.sendPositionThreshold = 0.0f

The position won't send unless it changed this much.

Set to 0 to always send the position of owned objects if it has changed since the last sent position, and for a hardware performance increase, but at the cost of network usage. If greater than 0, a synced object's position is only sent if its position is off from the last sent position by more than the threshold. Measured in distance units.

◆ sendRotationThreshold

float SmoothSync.sendRotationThreshold = 0.0f

The rotation won't send unless it changed this much.

Set to 0 to always send the rotation of owned objects if it has changed since the last sent rotation, and for a hardware performance increase, but at the cost of network usage. If greater than 0, a synced object's rotation is only sent if its rotation is off from the last sent rotation by more than the threshold. Measured in degrees.

◆ sendScaleThreshold

float SmoothSync.sendScaleThreshold = 0.0f

The scale won't send unless it changed this much.

Set to 0 to always send the scale of owned objects if it has changed since the last sent scale, and for a hardware performance increase, but at the cost of network usage. If greater than 0, a synced object's scale is only sent if its scale is off from the last sent scale by more than the threshold. Measured in distance units.

◆ sendVelocityThreshold

float SmoothSync.sendVelocityThreshold = 0.0f

The velocity won't send unless it changed this much.

Set to 0 to always send the velocity of owned objects if it has changed since the last sent velocity, and for a hardware performance increase, but at the cost of network usage. If greater than 0, a synced object's velocity is only sent if its velocity is off from the last sent velocity by more than the threshold. Measured in velocity units.

◆ setVelocityInsteadOfPositionOnNonOwners

bool SmoothSync.setVelocityInsteadOfPositionOnNonOwners = false

Set velocity on non-owners instead of the position.

Requires Rigidbody. Uses the synced position to determine what to set the velocity to on unowned objects. Will get rid of lag for game types where the camera follows along at a fast speed and you are trying to ride next to other synced fast speed objects. (e.g. racing, flying)

◆ snapPositionThreshold

float SmoothSync.snapPositionThreshold = 0

If a synced object's position is more than snapPositionThreshold units from the target position, it will jump to the target position immediately instead of lerping.

Set to zero to not use at all and use one less Vector3.Distance() check per frame if you also have receivedPositionThreshold at 0. Measured in distance units.

◆ snapRotationThreshold

float SmoothSync.snapRotationThreshold = 0

If a synced object's rotation is more than snapRotationThreshold from the target rotation, it will jump to the target rotation immediately instead of lerping.

Set to zero to not use at all and use one less Quaternion.Angle() check per frame if you also have receivedRotationThreshold at 0. Measured in degrees.

◆ snapScaleThreshold

float SmoothSync.snapScaleThreshold = 0

If a synced object's scale is more than snapScaleThreshold units from the target scale, it will jump to the target scale immediately instead of lerping.

Set to zero to not use at all and use one less Vector3.Distance() check per frame. Measured in distance units.

◆ snapTimeThreshold

float SmoothSync.snapTimeThreshold = 3.0f

The estimated owner time of non-owned objects will change instantly if it is off by this amount.

The estimated owner time will change instantly if the difference is larger than this amount (in seconds) when receiving an update. Generally keep at default unless you have a very low send rate and expect large variance in your latencies.

◆ stateBuffer

SmoothState [] SmoothSync.stateBuffer

Non-owners keep a list of recent States received over the network for interpolating.

Index 0 is the newest received State.

◆ syncAngularVelocity

SyncMode SmoothSync.syncAngularVelocity = SyncMode.XYZ

Angular velocity sync mode.

Fine tune how angular velocity is synced.

◆ syncPosition

SyncMode SmoothSync.syncPosition = SyncMode.XYZ

Position sync mode.

Fine tune how position is synced. For objects that don't move, use SyncMode.NONE

◆ syncRotation

SyncMode SmoothSync.syncRotation = SyncMode.XYZ

Rotation sync mode.

Fine tune how rotation is synced. For objects that don't rotate, use SyncMode.NONE

◆ syncScale

SyncMode SmoothSync.syncScale = SyncMode.XYZ

Scale sync mode.

Fine tune how scale is synced. For objects that don't scale, use SyncMode.NONE

◆ syncVelocity

SyncMode SmoothSync.syncVelocity = SyncMode.XYZ

Velocity sync mode.

Fine tune how velocity is synced.

◆ timeCorrectionSpeed

float SmoothSync.timeCorrectionSpeed = .1f

How fast to change the estimated owner time of non-owned objects. 0 is never, 5 is basically instant.

The estimated owner time can shift by this amount per second every frame. Lower values will be smoother but it may take longer to adjust to larger jumps in latency. Probably keep this lower than ~.5 unless you are having serious latency variance issues.

◆ useExtrapolationDistanceLimit

bool SmoothSync.useExtrapolationDistanceLimit = false

Whether or not you want to use the extrapolationDistanceLimit.

You can use only the extrapolationTimeLimit and save a distance check every extrapolation frame. Must be syncing velocity in order to utilize extrapolation.

◆ useExtrapolationTimeLimit

bool SmoothSync.useExtrapolationTimeLimit = true

Whether or not you want to use the extrapolationTimeLimit.

You can use only the extrapolationTimeLimit and save a distance check every extrapolation frame. Must be syncing velocity in order to utilize extrapolation.

◆ validateStateMethod

validateStateDelegate SmoothSync.validateStateMethod = validateState

Validation method variable.

Holds a reference to the method that will be called to validate incoming States. You will set it to your custom validation method. It will be something like smoothSync.validateStateMethod = myCoolCustomValidatePlayerMethod; in the Start or Awake method of your object's script.

◆ whenToUpdateTransform

WhenToUpdateTransform SmoothSync.whenToUpdateTransform = WhenToUpdateTransform.Update

Where the object's Transform is updated on non-owners.

Update will have smoother results but FixedUpdate might be better for physics.

Property Documentation

◆ approximateNetworkTimeOnOwner

float SmoothSync.approximateNetworkTimeOnOwner
getset

The current estimated time on the owner.

Time comes from the owner in every sync message. When it is received we set _ownerTime and lastTimeOwnerTimeWasSet. Then when we want to know what time it is we add time elapsed to the last _ownerTime we received.


The documentation for this class was generated from the following file: