Inherits UActorComponent.
Public Member Functions | |
void | addState (SmoothState *state) |
Add an incoming state to the stateBuffer on non-owned objects. More... | |
void | addTeleportState (SmoothState *state) |
Add the teleport State at the correct place in the State buffer. More... | |
void | adjustOwnerTime () |
Adjust owner time based on latest timestamp. More... | |
void | applyInterpolationOrExtrapolation () |
void | clearBuffer () |
Clear the state buffer. You will call this on all unowned Actor instances on ownership changes. More... | |
void | ClientSendsTransformToServer (const TArray< uint8 > &value) |
template<class T > | |
void | copyToBuffer (T thing) |
void | enableSmoothSync (bool enable) |
Used to turn Smooth Sync on and off. True to enable Smooth Sync. False to disable Smooth Sync. More... | |
char | encodeSyncInformation (bool sendPositionFlag, bool sendRotationFlag, bool sendScaleFlag, bool sendVelocityFlag, bool sendAngularVelocityFlag, bool atPositionalRestFlag, bool atRotationalRestFlag) |
Encode sync info based on what we want to send. More... | |
virtual void | EndPlay (const EEndPlayReason::Type EndPlayReason) override |
bool | extrapolate (float interpolationTime, SmoothState *targetState) |
Attempt to extrapolate from the newest SmoothState in the buffer More... | |
void | forceStateSendNextFrame () |
Forces the SmoothState to be sent on owned objects the next time it goes through Update(). More... | |
FVector | getAngularVelocity () |
Set scale of object. More... | |
float | getApproximateNetworkTimeOnOwner () |
The current estimated time on the owner. More... | |
FVector | getLinearVelocity () |
Set scale of object. More... | |
float | GetNetworkSendInterval () |
FVector | getPosition () |
Get position of object. More... | |
FQuat | getRotation () |
Get rotation of object. More... | |
FVector | getScale () |
Get scale of object. More... | |
void | internalEnableSmoothSync (bool enable) |
void | interpolate (float interpolationTime, SmoothState *targetState) |
Interpolate between two States from the stateBuffer in order calculate the targetState. More... | |
bool | isSyncingXAngularVelocity () |
Determine if should be syncing. More... | |
bool | isSyncingXPosition () |
Determine if should be syncing. More... | |
bool | isSyncingXRotation () |
Determine if should be syncing. More... | |
bool | isSyncingXScale () |
Determine if should be syncing. More... | |
bool | isSyncingXVelocity () |
Determine if should be syncing. More... | |
bool | isSyncingYAngularVelocity () |
Determine if should be syncing. More... | |
bool | isSyncingYPosition () |
Determine if should be syncing. More... | |
bool | isSyncingYRotation () |
Determine if should be syncing. More... | |
bool | isSyncingYScale () |
Determine if should be syncing. More... | |
bool | isSyncingYVelocity () |
Determine if should be syncing. More... | |
bool | isSyncingZAngularVelocity () |
Determine if should be syncing. More... | |
bool | isSyncingZPosition () |
Determine if should be syncing. More... | |
bool | isSyncingZRotation () |
Determine if should be syncing. More... | |
bool | isSyncingZScale () |
Determine if should be syncing. More... | |
bool | isSyncingZVelocity () |
Determine if should be syncing. More... | |
template<class T > | |
void | readFromBuffer (T *thing) |
void | resetFlags () |
bool | sameVector (FVector one, FVector two, float threshold) |
void | sendState () |
void | SerializeState (SmoothState *sendingState) |
void | ServerSendsTransformToEveryone (const TArray< uint8 > &value) |
void | setAngularVelocity (FVector position) |
Set scale of object. More... | |
void | setLinearVelocity (FVector position) |
Set scale of object. More... | |
void | setPosition (FVector position) |
Set position of object. More... | |
void | setRotation (const FQuat &rotation) |
Set rotation of object. More... | |
void | setScale (FVector scale) |
Set scale of object. More... | |
void | setSceneComponentToSync (USceneComponent *theComponent) |
If you want to track a scene component, assign it, otherwise it will just sync the actor the SmoothSync is on. Must have one SmoothSync for each Transform that you want to sync. More... | |
bool | shouldSendAngularVelocity () |
Check if angular velocity has changed enough. More... | |
bool | shouldSendPosition () |
Check if position has changed enough. More... | |
bool | shouldSendRotation () |
Check if rotation has changed enough. More... | |
bool | shouldSendScale () |
Check if scale has changed enough. More... | |
bool | shouldSendTransform () |
Determines if we should be trying to send out the Transform. More... | |
bool | shouldSendVelocity () |
Check if velocity has changed enough. More... | |
bool | shouldSyncAngularVelocity (char syncInformation) |
Decode sync info to see if we want to sync angular velocity. More... | |
bool | shouldSyncPosition (char syncInformation) |
Decode sync info to see if we want to sync position. More... | |
bool | shouldSyncPositionalRest (char syncInformation) |
Decode sync info to see if we want to sync angular velocity. More... | |
bool | shouldSyncRotation (char syncInformation) |
Decode sync info to see if we want to sync rotation. More... | |
bool | shouldSyncRotationalRest (char syncInformation) |
Decode sync info to see if we want to sync angular velocity. More... | |
bool | shouldSyncScale (char syncInformation) |
Decode sync info to see if we want to sync scale. More... | |
bool | shouldSyncVelocity (char syncInformation) |
Decode sync info to see if we want to sync velocity. More... | |
void | shouldTeleport (SmoothState *start, SmoothState *end, float interpolationTime, float *t) |
void | SmoothSyncEnableClientToServer (bool enable) |
void | SmoothSyncEnableServerToClients (bool enable) |
void | SmoothSyncTeleportClientToServer (FVector position, FVector rotation, FVector scale, float tempOwnerTime) |
void | SmoothSyncTeleportServerToClients (FVector position, FVector rotation, FVector scale, float tempOwnerTime) |
void | stopLerping () |
Stop updating the States of non-owned objects so that the object can be teleported. More... | |
void | teleport () |
Teleport the player so that position will not be interpolated on non-owners. More... | |
virtual void | TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override |
USmoothSync () | |
Sets default values for this component's properties. | |
Public Attributes | |
float | _ownerTime |
The last owner time received over the network More... | |
char | angularVelocityMask = 16 |
Hardcoded information to determine angular velocity syncing. More... | |
float | approximateNetworkTimeOnOwner = 0 |
char | atPositionalRestMask = 64 |
Hardcoded information to determine if at positional rest. More... | |
float | atRestPositionThreshold = .05f |
Actor will come to positional rest if it stops moving by this amount. Used to smooth out stops and starts. More... | |
float | atRestRotationThreshold = .1f |
Actor will come to rotational rest if it stops rotating by this amount. Used to smooth out stops and starts. More... | |
float | atRestThresholdCount = .5f |
Is considered at rest if at same position for this many FixedUpdate()s. More... | |
unsigned char | atRotationalRestMask = 128 |
Hardcoded information to determine if at rotational rest. More... | |
int | calculatedStateBufferSize = ((int)(sendRate * interpolationBackTime) + 1) * 2 |
Uses a State buffer of at least 30 for ease of use, or a buffer size in relation to the send rate and how far back in time we want to be. Doubled buffer as estimation for forced SmoothState sends. More... | |
bool | changedPositionLastFrame |
Used to tell whether the object is at positional rest or not. More... | |
bool | changedRotationLastFrame |
Used to tell whether the object is at rotational rest or not. More... | |
bool | dontLerp = false |
Used via stopLerping() to 'teleport' a synced object without unwanted lerping. Useful for player spawning and whatnot. More... | |
bool | extrapolatedLastFrame |
float | extrapolationDistanceLimit = 100.0f |
How much distance into the future a non-owned object is allowed to extrapolate. More... | |
SmoothState * | extrapolationEndState |
SmoothState when extrapolation ended. More... | |
ExtrapolationMode | extrapolationMode = ExtrapolationMode::LIMITED |
The amount of extrapolation used. More... | |
float | extrapolationStopTime |
Time when extrapolation ended. More... | |
float | extrapolationTimeLimit = 1.0f |
How much time into the future a non-owned object is allowed to extrapolate. More... | |
bool | forceStateSend = false |
Gets set to true in order to force the state to be sent next frame on owners. More... | |
float | interpolationBackTime = .1f |
How much time in the past non-owned objects should be. More... | |
bool | isAngularVelocityCompressed = false |
Compress angular velocity floats when sending over the network. More... | |
bool | isBeingUsed = true |
Used to turn Smooth Sync off and on. More... | |
bool | isPositionCompressed = false |
Compress position floats when sending over the network. More... | |
bool | isRotationCompressed = false |
Compress rotation floats when sending over the network. More... | |
bool | isScaleCompressed = false |
Compress scale floats when sending over the network. More... | |
bool | isSimulatingPhysics |
bool | isVelocityCompressed = false |
Compress velocity floats when sending over the network. More... | |
FVector | lastAngularVelocityWhenStateWasSent |
Angular velocity owner was at when the last angular velociy SmoothState was sent. More... | |
FVector | lastPositionWhenStateWasSent |
Position owner was at when the last position SmoothState was sent. More... | |
FQuat | lastRotationWhenStateWasSent = FQuat::Identity |
Rotation owner was at when the last rotation SmoothState was sent. More... | |
FVector | lastScaleWhenStateWasSent |
Scale owner was at when the last scale SmoothState was sent. More... | |
float | lastTeleportOwnerTime |
Last time the object was teleported. More... | |
float | lastTimeOwnerTimeWasSet |
The realTimeSinceStartup when we received the last owner time. More... | |
float | lastTimeStateWasReceived |
Last time a SmoothState was received on non-owner. More... | |
float | lastTimeStateWasSent |
Last time owner sent a SmoothState. More... | |
FVector | lastVelocityWhenStateWasSent |
Velocity owner was at when the last velocity SmoothState was sent. More... | |
SmoothState * | latestEndStateUsed |
Used to check if low FPS causes us to skip a teleport State. More... | |
FVector | latestReceivedAngularVelocity |
FVector | latestReceivedVelocity |
FVector | latestTeleportedFromPosition |
Used to check if we should be sending a "JustStartedMoving" State. If we are teleporting, don't send one. More... | |
FQuat | latestTeleportedFromRotation |
Used to check if we should be sending a "JustStartedMoving" State. If we are teleporting, don't send one. More... | |
FVector | positionLastFrame |
float | positionLerpSpeed = .85f |
How fast to lerp the position to the target SmoothState. 0 is never, 1 is instant. More... | |
char | positionMask = 1 |
Hardcoded information to determine rotation syncing. More... | |
float | positionSnapThreshold = 500 |
If a synced object's position is more than positionSnapThreshold units from the target position, it will jump to the target position immediately instead of lerping. More... | |
UPrimitiveComponent * | primitiveComponent |
Reference to the Primitive Component. More... | |
USceneComponent * | realComponentToSync |
Gets assigned to the real transform to sync. Use SetSceneComponentToSync() method to set it up. If this variable is not assigned, SmoothSync will sync the actor. More... | |
AActor * | realObjectToSync |
Gets assigned to the real object to sync. More... | |
float | receivedPositionThreshold = 0.0f |
The position won't be set on non-owned objects unless it changed this much. More... | |
float | receivedRotationThreshold = 0.0f |
The rotation won't be set on non-owned objects unless it changed this much. More... | |
int | receivedStatesCounter |
RestState | restStatePosition = RestState::MOVING |
RestState | restStateRotation = RestState::MOVING |
FQuat | rotationLastFrame |
float | rotationLerpSpeed = .85f |
How fast to lerp the rotation to the target State. 0 is never, 1 is instant.. More... | |
char | rotationMask = 2 |
Hardcoded information to determine rotation syncing. More... | |
float | rotationSnapThreshold = 100 |
If a synced object's rotation is more than rotationSnapThreshold from the target rotation, it will jump to the target rotation immediately instead of lerping. More... | |
float | samePositionCount |
Counts up for each FixedUpdate() that position is the same until the atRestThresholdCount. More... | |
float | sameRotationCount |
Counts up for each FixedUpdate() that rotation is the same until the atRestThresholdCount. More... | |
float | scaleLerpSpeed = .85f |
How fast to lerp the scale to the target State. 0 is never, 1 is instant. More... | |
char | scaleMask = 4 |
Hardcoded information to determine scale syncing. More... | |
float | scaleSnapThreshold = 3 |
If a synced object's scale is more than scaleSnapThreshold units from the target scale, it will jump to the target scale immediately instead of lerping. More... | |
bool | sendAngularVelocity = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame. More... | |
float | sendAngularVelocityThreshold = 0.0f |
The angular velocity won't send unless one of its Vector values changed this much. More... | |
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. More... | |
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. More... | |
SmoothState * | sendingTempState |
SmoothState we fill up to better organize the data before sending it out. More... | |
bool | sendPosition = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame. More... | |
float | sendPositionThreshold = 0.0f |
The position won't send unless one of its Vector values has changed this much. More... | |
float | sendRate = 30 |
How many times per second to send network updates. More... | |
bool | sendRotation = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame. More... | |
float | sendRotationThreshold = 0.0f |
The rotation won't send unless one of its Vector values has changed this much. More... | |
bool | sendScale = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame. More... | |
float | sendScaleThreshold = 0.0f |
The scale won't send unless one of its Vector values it changed this much. More... | |
bool | sendVelocity = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame. More... | |
float | sendVelocityThreshold = 0.0f |
The velocity won't send unless one of its Vector values changed this much. More... | |
float | snapTimeThreshold = 5.0f |
The estimated owner time of non-owned objects will change instantly if it is off by this amount. More... | |
SmoothState ** | stateBuffer |
Non-owners keep a list of recent States received over the network for interpolating. More... | |
int | stateCount = 0 |
The number of States in the stateBuffer More... | |
SyncMode | syncAngularVelocity = SyncMode::XYZ |
Angular velocity sync mode More... | |
SyncMode | syncPosition = SyncMode::XYZ |
Position sync mode More... | |
SyncMode | syncRotation = SyncMode::XYZ |
Rotation sync mode More... | |
SyncMode | syncScale = SyncMode::XYZ |
Scale sync mode More... | |
SyncMode | syncVelocity = SyncMode::XYZ |
Velocity sync mode More... | |
SmoothState * | targetTempState |
Gets filled each frame with a SmoothState to move towards More... | |
char | teleportMask = 32 |
Hardcoded information to determine if teleporting. More... | |
float | timeCorrectionSpeed = .1f |
How fast to change the estimated owner time of non-owned objects. 0 is never, 5 is basically instant. More... | |
float | timeSpentExtrapolating |
bool | triedToExtrapolateTooFar |
float | updatedDeltaTime |
bool | useExtrapolationDistanceLimit |
Whether or not to have an extrapolation distance limit. More... | |
bool | useExtrapolationTimeLimit = true |
Whether or not to have an extrapolation time limit. More... | |
char | velocityMask = 8 |
Hardcoded information to determine velocity syncing. More... | |
Protected Member Functions | |
virtual void | BeginPlay () override |
void USmoothSync::addState | ( | SmoothState * | state | ) |
Add an incoming state to the stateBuffer on non-owned objects.
void USmoothSync::addTeleportState | ( | SmoothState * | teleportState | ) |
Add the teleport State at the correct place in the State buffer.
void USmoothSync::adjustOwnerTime | ( | ) |
Adjust owner time based on latest timestamp.
void USmoothSync::clearBuffer | ( | ) |
Clear the state buffer. You will call this on all unowned Actor instances on ownership changes.
Effectively clear the state buffer. Used for teleporting and ownership changes.
void USmoothSync::enableSmoothSync | ( | bool | enable | ) |
Used to turn Smooth Sync on and off. True to enable Smooth Sync. False to disable Smooth Sync.
Used to turn Smooth Sync on and off. True to enable Smooth Sync. False to disable Smooth Sync. Will automatically send RPCs across the network. Is meant to be called on the owned version of the Actor.
Will automatically send RPCs across the network. Is meant to be called on the owned version of the Actor.
char USmoothSync::encodeSyncInformation | ( | bool | sendPositionFlag, |
bool | sendRotationFlag, | ||
bool | sendScaleFlag, | ||
bool | sendVelocityFlag, | ||
bool | sendAngularVelocityFlag, | ||
bool | atPositionalRestFlag, | ||
bool | atRotationalRestFlag | ||
) |
Encode sync info based on what we want to send.
bool USmoothSync::extrapolate | ( | float | interpolationTime, |
SmoothState * | targetState | ||
) |
Attempt to extrapolate from the newest SmoothState in the buffer
interpolationTime | The target time |
void USmoothSync::forceStateSendNextFrame | ( | ) |
Forces the SmoothState to be sent on owned objects the next time it goes through Update().
Forces the SmoothState (Transform) to be sent on owned objects the next time it goes through TickComponent(). The SmoothState (Transform) will get sent next frame regardless of all limitations.
The SmoothState will get sent next frame regardless of all limitations.
FVector USmoothSync::getAngularVelocity | ( | ) |
Set scale of object.
float USmoothSync::getApproximateNetworkTimeOnOwner | ( | ) |
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.
FVector USmoothSync::getLinearVelocity | ( | ) |
Set scale of object.
FVector USmoothSync::getPosition | ( | ) |
Get position of object.
FQuat USmoothSync::getRotation | ( | ) |
Get rotation of object.
FVector USmoothSync::getScale | ( | ) |
Get scale of object.
void USmoothSync::interpolate | ( | float | interpolationTime, |
SmoothState * | targetState | ||
) |
Interpolate between two States from the stateBuffer in order calculate the targetState.
interpolationTime | The target time |
bool USmoothSync::isSyncingXAngularVelocity | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingXPosition | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingXRotation | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingXScale | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingXVelocity | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingYAngularVelocity | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingYPosition | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingYRotation | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingYScale | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingYVelocity | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingZAngularVelocity | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingZPosition | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingZRotation | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingZScale | ( | ) |
Determine if should be syncing.
bool USmoothSync::isSyncingZVelocity | ( | ) |
Determine if should be syncing.
void USmoothSync::setAngularVelocity | ( | FVector | angularVelocity | ) |
Set scale of object.
void USmoothSync::setLinearVelocity | ( | FVector | linearVelocity | ) |
Set scale of object.
void USmoothSync::setPosition | ( | FVector | position | ) |
Set position of object.
void USmoothSync::setRotation | ( | const FQuat & | rotation | ) |
Set rotation of object.
void USmoothSync::setScale | ( | FVector | scale | ) |
Set scale of object.
void USmoothSync::setSceneComponentToSync | ( | USceneComponent * | componentToSync | ) |
If you want to track a scene component, assign it, otherwise it will just sync the actor the SmoothSync is on. Must have one SmoothSync for each Transform that you want to sync.
Used to set the transform that you want to sync on this SmoothSync. If this is not called, SmoothSync will sync the actor. Must have one SmoothSync for each Transform that you want to sync.
bool USmoothSync::shouldSendAngularVelocity | ( | ) |
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.
bool USmoothSync::shouldSendPosition | ( | ) |
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.
bool USmoothSync::shouldSendRotation | ( | ) |
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.
bool USmoothSync::shouldSendScale | ( | ) |
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.
bool USmoothSync::shouldSendTransform | ( | ) |
Determines if we should be trying to send out the Transform.
Rules for sending Transform. Owned Actors: Owner determines position and sends out Transform. Unowned Actors: Server determines position and sends out Transform.
bool USmoothSync::shouldSendVelocity | ( | ) |
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.
bool USmoothSync::shouldSyncAngularVelocity | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync angular velocity.
bool USmoothSync::shouldSyncPosition | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync position.
bool USmoothSync::shouldSyncPositionalRest | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync angular velocity.
bool USmoothSync::shouldSyncRotation | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync rotation.
bool USmoothSync::shouldSyncRotationalRest | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync angular velocity.
bool USmoothSync::shouldSyncScale | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync scale.
bool USmoothSync::shouldSyncVelocity | ( | char | syncInformation | ) |
Decode sync info to see if we want to sync velocity.
void USmoothSync::stopLerping | ( | ) |
Stop updating the States of non-owned objects so that the object can be teleported.
void USmoothSync::teleport | ( | ) |
Teleport the player so that position will not be interpolated on non-owners.
Teleport the player so that position will not be interpolated on non-owners. Use teleport() on the owner and the Actor will jump to the current owner's position on non-owners.
Use teleport() on the owner and the Actor will jump to the current owner's position on non-owners.
float USmoothSync::_ownerTime |
The last owner time received over the network
char USmoothSync::angularVelocityMask = 16 |
Hardcoded information to determine angular velocity syncing.
char USmoothSync::atPositionalRestMask = 64 |
Hardcoded information to determine if at positional rest.
float USmoothSync::atRestPositionThreshold = .05f |
Actor will come to positional rest if it stops moving by this amount. Used to smooth out stops and starts.
float USmoothSync::atRestRotationThreshold = .1f |
Actor will come to rotational rest if it stops rotating by this amount. Used to smooth out stops and starts.
float USmoothSync::atRestThresholdCount = .5f |
Is considered at rest if at same position for this many FixedUpdate()s.
unsigned char USmoothSync::atRotationalRestMask = 128 |
Hardcoded information to determine if at rotational rest.
int USmoothSync::calculatedStateBufferSize = ((int)(sendRate * interpolationBackTime) + 1) * 2 |
Uses a State buffer of at least 30 for ease of use, or a buffer size in relation to the send rate and how far back in time we want to be. Doubled buffer as estimation for forced SmoothState sends.
bool USmoothSync::changedPositionLastFrame |
Used to tell whether the object is at positional rest or not.
bool USmoothSync::changedRotationLastFrame |
Used to tell whether the object is at rotational rest or not.
bool USmoothSync::dontLerp = false |
Used via stopLerping() to 'teleport' a synced object without unwanted lerping. Useful for player spawning and whatnot.
float USmoothSync::extrapolationDistanceLimit = 100.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.
Measured in distance units.
SmoothState* USmoothSync::extrapolationEndState |
SmoothState when extrapolation ended.
ExtrapolationMode USmoothSync::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.
float USmoothSync::extrapolationStopTime |
Time when extrapolation ended.
float USmoothSync::extrapolationTimeLimit = 1.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.
Measured in seconds.
bool USmoothSync::forceStateSend = false |
Gets set to true in order to force the state to be sent next frame on owners.
float USmoothSync::interpolationBackTime = .1f |
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.
Increasing 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 will make extrapolation more likely to be used, this will increase reponsiveness, 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 this higher than SendRate/100 to attempt to always interpolate. Keep in mind your send rate may fluctuate depending on your Unreal NetpdateFrequency settings and NetPriority.
Measured in seconds.
bool USmoothSync::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.
bool USmoothSync::isBeingUsed = true |
Used to turn Smooth Sync off and on.
bool USmoothSync::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.
bool USmoothSync::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.
bool USmoothSync::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.
bool USmoothSync::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.
FVector USmoothSync::lastAngularVelocityWhenStateWasSent |
Angular velocity owner was at when the last angular velociy SmoothState was sent.
FVector USmoothSync::lastPositionWhenStateWasSent |
Position owner was at when the last position SmoothState was sent.
FQuat USmoothSync::lastRotationWhenStateWasSent = FQuat::Identity |
Rotation owner was at when the last rotation SmoothState was sent.
FVector USmoothSync::lastScaleWhenStateWasSent |
Scale owner was at when the last scale SmoothState was sent.
float USmoothSync::lastTeleportOwnerTime |
Last time the object was teleported.
float USmoothSync::lastTimeOwnerTimeWasSet |
The realTimeSinceStartup when we received the last owner time.
float USmoothSync::lastTimeStateWasReceived |
Last time a SmoothState was received on non-owner.
float USmoothSync::lastTimeStateWasSent |
Last time owner sent a SmoothState.
FVector USmoothSync::lastVelocityWhenStateWasSent |
Velocity owner was at when the last velocity SmoothState was sent.
SmoothState* USmoothSync::latestEndStateUsed |
Used to check if low FPS causes us to skip a teleport State.
FVector USmoothSync::latestTeleportedFromPosition |
Used to check if we should be sending a "JustStartedMoving" State. If we are teleporting, don't send one.
FQuat USmoothSync::latestTeleportedFromRotation |
Used to check if we should be sending a "JustStartedMoving" State. If we are teleporting, don't send one.
float USmoothSync::positionLerpSpeed = .85f |
How fast to lerp the position to the target SmoothState. 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.
char USmoothSync::positionMask = 1 |
Hardcoded information to determine rotation syncing.
float USmoothSync::positionSnapThreshold = 500 |
If a synced object's position is more than positionSnapThreshold 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 distance check per frame if you also have receivedPositionThreshold at 0.
Measured in distance units.
UPrimitiveComponent* USmoothSync::primitiveComponent |
Reference to the Primitive Component.
USceneComponent* USmoothSync::realComponentToSync |
Gets assigned to the real transform to sync. Use SetSceneComponentToSync() method to set it up. If this variable is not assigned, SmoothSync will sync the actor.
AActor* USmoothSync::realObjectToSync |
Gets assigned to the real object to sync.
float USmoothSync::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 distance check per frame if you also have positionSnapThreshold 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.
float USmoothSync::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 FQuat.AngularDistance() check per frame if you also have rotationSnapThreshold 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.
float USmoothSync::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.
char USmoothSync::rotationMask = 2 |
Hardcoded information to determine rotation syncing.
float USmoothSync::rotationSnapThreshold = 100 |
If a synced object's rotation is more than rotationSnapThreshold 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 FQuat.AnglularDistance() check per frame if you also have receivedRotationThreshold at 0.
Measured in degrees.
float USmoothSync::samePositionCount |
Counts up for each FixedUpdate() that position is the same until the atRestThresholdCount.
float USmoothSync::sameRotationCount |
Counts up for each FixedUpdate() that rotation is the same until the atRestThresholdCount.
float USmoothSync::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.
char USmoothSync::scaleMask = 4 |
Hardcoded information to determine scale syncing.
float USmoothSync::scaleSnapThreshold = 3 |
If a synced object's scale is more than scaleSnapThreshold 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 distance check per frame.
Measured in distance units.
bool USmoothSync::sendAngularVelocity = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame.
float USmoothSync::sendAngularVelocityThreshold = 0.0f |
The angular velocity won't send unless one of its Vector values 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.
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 radians per second.
bool USmoothSync::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 USmoothSync::sendAtRotationalRestMessage = false |
Gets set to true when rotation is the same for two frames in order to tell non-owners to stop extrapolating rotation.
SmoothState* USmoothSync::sendingTempState |
SmoothState we fill up to better organize the data before sending it out.
bool USmoothSync::sendPosition = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame.
float USmoothSync::sendPositionThreshold = 0.0f |
The position won't send unless one of its Vector values has changed this much.
Set to 0 to always send the position of owned objects if it has changed since the last sent position.
If greater than 0, a synced object's position is only sent if its vector position value is off from the last sent position by more than the threshold.
Measured in distance units.
float USmoothSync::sendRate = 30 |
How many times per second to send network updates.
Keep in mind this can be limited by Unreal's Net Update Frequency.
bool USmoothSync::sendRotation = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame.
float USmoothSync::sendRotationThreshold = 0.0f |
The rotation won't send unless one of its Vector values has changed this much.
Set to 0 to always send the rotation of owned objects if it has changed since the last sent rotation.
If greater than 0, a synced object's rotation is only sent if its euler value is off from the last sent rotation by more than the threshold.
Measured in degrees.
bool USmoothSync::sendScale = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame.
float USmoothSync::sendScaleThreshold = 0.0f |
The scale won't send unless one of its Vector values it changed this much.
Set to 0 to always send the scale of owned objects if it has changed since the last sent scale.
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.
bool USmoothSync::sendVelocity = true |
Variable we set at the beginning of Update so we only need to do the checks once a frame.
float USmoothSync::sendVelocityThreshold = 0.0f |
The velocity won't send unless one of its Vector values changed this much.
Set to 0 to always send the velocity of owned objects if it has changed since the last sent velocity.
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.
float USmoothSync::snapTimeThreshold = 5.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.
SmoothState** USmoothSync::stateBuffer |
Non-owners keep a list of recent States received over the network for interpolating.
Index 0 is the newest received State.
int USmoothSync::stateCount = 0 |
The number of States in the stateBuffer
SyncMode USmoothSync::syncAngularVelocity = SyncMode::XYZ |
Angular velocity sync mode
Fine tune how angular velocity is synced.
SyncMode USmoothSync::syncPosition = SyncMode::XYZ |
Position sync mode
Fine tune how position is synced. For objects that don't move, use SyncMode.NONE
SyncMode USmoothSync::syncRotation = SyncMode::XYZ |
Rotation sync mode
Fine tune how rotation is synced. For objects that don't rotate, use SyncMode.NONE
SyncMode USmoothSync::syncScale = SyncMode::XYZ |
Scale sync mode
Fine tune how scale is synced. For objects that don't scale, use SyncMode.NONE
SyncMode USmoothSync::syncVelocity = SyncMode::XYZ |
Velocity sync mode
Fine tune how velocity is synced.
SmoothState* USmoothSync::targetTempState |
Gets filled each frame with a SmoothState to move towards
char USmoothSync::teleportMask = 32 |
Hardcoded information to determine if teleporting.
float USmoothSync::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 will shift by at most this amount per second. Lower values will be smoother but it may take a bit to adjust to larger jumps in latency. Probably keep this lower than ~.6 unless you are having serious latency variance issues.
bool USmoothSync::useExtrapolationDistanceLimit |
Whether or not to have an extrapolation distance limit.
bool USmoothSync::useExtrapolationTimeLimit = true |
Whether or not to have an extrapolation time limit.
char USmoothSync::velocityMask = 8 |
Hardcoded information to determine velocity syncing.