Movement Synchronization¶
The vast majority of real-time multiplayer games require synchronization of location, direction, and velocity to accurately reflect the player’s movement within the world.
The Strix Replicator Component is required for synchronization; however, while it can synchronize Actor properties, it only synchronizes specific variables as configured. These do not include the existing transform and velocity properties that Unreal world Actors contain.
While it would be possible to manually sync these properties, Strix provides the Strix Movement Synchronizer for this purpose.
The Strix Movement Synchronizer Component¶
Note
Simple location synchronization can be performed by the more lightweight Strix Transform Sync component. See Transform Synchronization.
The Strix Movement Synchronizer can be added to any Actor with a Strix Replicator Component. The Movement Synchronizer updates a replica Actor’s position and velocity based on their owner’s movement.
It is designed to perform prediction, and to smoothly move an object to the correct position over each frame. This makes it ideal for objects that move rapidly and in complex motions, and that need to appear natural, as if the object is not being controlled by a player many miles away.
It is best used on Pawns with PawnMovementComponents. While it can be used on other Actors, this will generate a warning and fallback to positional updating rather than the default velocity updating, which will affect the smoothness of the synchronization. It is much more performance intensive than the Strix Transform Sync component (See Transform Synchronization) but makes movements much smoother.
The Movement Synchronizer is the most complex Component in the Strix Unreal SDK, as it contains a number of settings. The precision and smoothness of movement synchronization depends on the particular movement type of the Actors. It is recommended that developers play around with the settings below to determine the most appropriate values for their particular use case. The Strix Unreal Sample has different movement settings between different types of Actors.
Near Distance |
float |
The acceptable error distance from the current location to the desired location.
Setting this too high may cause rubber banding.
|
|
Max Speed |
float |
The max speed this Actor will travel.
Setting this too low will result in jumpy movement.
Setting this too high may result in Actors moving unnaturally fast.
|
|
Acceleration |
float |
The max acceleration this Actor will be under.
Setting this too low will result in jumpy movement.
Setting this too high may result in Actors accelerating unnaturally fast.
|
|
Damping |
float |
A smoothing value.
Using a low value will make the interpolation smoother
but using a high value will make the movement less reactive.
|
|
Sync Period Min |
int |
This is the minimum amount of time in milliseconds between updates.
The smaller this value is, the more updates we make,
and therefore the more accurate the movement becomes, at the cost of network bandwidth.
|
|
Sync Period Max |
int |
This is the maximum amount of time in milliseconds between updates.
The smaller this value is, the more updates we make when still.
In conjunction with Sync Period Min, this allows some network performance
to be saved when we are not moving much.
|
|
Reachable Distance |
float |
This is the maximum distance we can travel in one update.
Setting this value too low can cause jumpy movement as the algorithm cannot keep up.
Of note is the behavior seen when climbing;
be aware that, if you make three-dimensional movement when synchronizing in two-dimensional space,
the actual movement distance is usually greater than what the algorithm expects
(see the note on bMaintainHorizontalGroundVelocity on UCharacterMovementComponent of Unreal Engine).
|
|
Movement Sync Type |
RPC or Sync Properties |
RPC is the default, where updates are made by remote procedure calls every update tick.
Sync Properties will use Strix’s internal syncing logic.
Sync Properties will retain the most
up to date sync data on the server, but this is more performance heavy on the server.
|
|
Sync Jump |
bool |
The default is set to true.
If enabled, this Component will call the Character::Jump() method
on the replicated Actor when the original Actor Jumps (if the replica is not falling).
This only works on Character Actors and provides a simple way of implementing synced jumping.
However, if you have complicated jump logic, you may want to disable this
and use either the Strix Blueprint RPC functions or the Sync Z Velocity option, or both.
|
|
Sync X Velocity |
bool |
This option controls whether to synchronize the velocity in the X direction.
The default is set to true. Disable this if you never move in the X direction.
|
|
Sync Y Velocity |
bool |
This option controls whether to synchronize the velocity in the Y direction.
The default is set to true. Disable this if you never move in the Y direction.
|
|
Sync Z Velocity |
bool |
This option controls whether to synchronize the velocity in the Z direction.
The default is set to false.
Typically, games involve gravity in the Z direction,
and Replicas are also affected by gravity and will fall correctly and interact with environments
(like terrain) without the need for the Z velocity to be synchronized.
However, if you are using a lot of up and down movement in your game,
are flying, or allow control on the Z axis (e.g., a jetpack), then you should enable this option.
|
|
Interpolate Rotation |
bool |
The default is set to true.
If enabled, rotations will also be interpolated using Spherical Linear Interpolation (SLERP);
otherwise, rotations will be updated directly.
Disable this option if you do not need smooth rotation and want a small performance gain.
|
|
Send RPC Spawn |
bool |
The default is set to true.
If enabled, when an Actor with this synchronizer is spawned remotely,
its position will be updated immediately.
|