FCharacterNetDriver
Character movement over the network, UE CharacterMovement-shaped. The client records a move per send (its input and the time it covers), predicts it locally and sends it with the moves the server has not acknowledged yet. The server queues every move per player and steps the pawn once per move, in order, with that move's time, through the same code the frame runs (CharacterMovementSystem::StepMovement + PhysicsSystem::StepCharacter); the ack names the last move it actually stepped. The client then rewinds to the server's pose, replays what is still unacknowledged, and hides the jump with a decaying visual offset.
- Module
- Networking
- Header
#include "Networking/Replication/CharacterNetDriver.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using FStepFn = std::function<bool(uint64_t entityId, const ReplicationInputBody& cmd, float dt)> | |
using FSendFn = std::function<void(const ReplicationInputBody& move)> | |
using FActorMoveApplyFn = bool (*)(World& world, uint64_t entity, const Vec3& moveDir, bool sprint, bool crouch, bool jump) | Actor-path movement apply (E3.1 N2). The driver itself knows only entities; the Game module installs this so server inputs drive the pawn's MCharacterMovementComponent (jump buffering, mode machine) when an actor world exists. Return false to fall through to the raw ECS CharacterMovementComponent path. Plain fn ptr — this crosses a DLL boundary once the driver moves down into Networking. |
Constructors
| Signature | Name | Description |
|---|---|---|
FCharacterNetDriver() = default | FCharacterNetDriver | |
~FCharacterNetDriver() override = default | ~FCharacterNetDriver |
Public functions
| Returns | Name | Description |
|---|---|---|
void | SetActorMoveApplyHook | |
void | Initialize | |
void | Shutdown | |
void | Update | |
void | SetStepFunction | |
void | SetMoveSendFunction | |
void | SetLocalPawn | |
uint64_t | GetLocalPawn | |
uint32_t | GetReconcileCount | |
uint32_t | GetCorrectionCount | |
float | GetLastCorrectionError | |
bool | ServerApplyInput | Server: queue one move from a player. |
void | ServerConsumeMoves | Server: step every queued move of every player whose time the server's clock has covered. |
size_t | GetQueuedMoveCount | |
uint32_t | GetServerMovesStepped | |
bool | StepPawn | |
void | RecordPredictedStep | |
bool | ClientReconcileAgainst | |
bool | ClientReconcileAgainst | The full form: the server's movement state rides along and the replay starts from it (velocity, mode, timers), not from the client's own. |
void | ClientReconcile | |
Vec3 | GetCorrectionOffset | Client: the visual offset still hiding the last correction. |
void | ClientApplySmoothing | |
uint16_t | BuildButtonMask | |
uint16_t | BuildButtonMask | |
void | WriteNetMovementState | Server: publish the pawn's movement state into its NetMovementState component (added on first use) after a move. |
bool | ReadNetMovementState | Client: the server's movement state from the replicated shadow, with the fields the snapshot does not carry (root-motion sources) taken from local. |
uint16_t | EncodeMoveSeconds | |
float | MoveSeconds | |
float | QuantizeMoveAxis | |
float | QuantizeLookAxis | |
void | QuantizeMove | |
bool | CanCombineMoves | |
void | ClientSubmitMove | |
void | ClientCapturePredictedPose | |
void | ClientFlushHeldMove | |
bool | HasHeldMove | |
float | GetHeldMoveSeconds | |
uint32_t | GetCombinedMoveCount | |
uint32_t | GetSentMoveCount | |
size_t | GetPredictedStepCount |
Function details
FCharacterNetDriver
FCharacterNetDriver() = default~FCharacterNetDriver
~FCharacterNetDriver() override = defaultSetActorMoveApplyHook
static void SetActorMoveApplyHook(FActorMoveApplyFn fn)Initialize
void Initialize(World* world) overrideShutdown
void Shutdown() overrideUpdate
void Update(float deltaTime) overrideSetStepFunction
void SetStepFunction(FStepFn fn)SetMoveSendFunction
void SetMoveSendFunction(FSendFn fn)SetLocalPawn
void SetLocalPawn(uint64_t entityId)GetLocalPawn
uint64_t GetLocalPawn() constGetReconcileCount
uint32_t GetReconcileCount() constGetCorrectionCount
uint32_t GetCorrectionCount() constGetLastCorrectionError
float GetLastCorrectionError() constServerApplyInput
bool ServerApplyInput(uint32_t senderPeerId, const ReplicationInputBody& body)Server: queue one move from a player. False when the peer has no pawn.
ServerConsumeMoves
void ServerConsumeMoves(float deltaTime)Server: step every queued move of every player whose time the server's clock has covered. Update calls it on a host each frame.
GetQueuedMoveCount
size_t GetQueuedMoveCount(uint32_t peerId) constGetServerMovesStepped
uint32_t GetServerMovesStepped() constStepPawn
bool StepPawn(uint64_t entityId, const ReplicationInputBody& cmd, float dt)RecordPredictedStep
void RecordPredictedStep(uint32_t clientTick, const ReplicationInputBody& cmd, float dt, const Vec3& predictedPosition)ClientReconcileAgainst
bool ClientReconcileAgainst(const Vec3& authoritativePosition, uint32_t ackTick)ClientReconcileAgainst
bool ClientReconcileAgainst(const Vec3& authoritativePosition, const FCharacterMoveState* authoritativeState, uint32_t ackTick)The full form: the server's movement state rides along and the replay starts from it (velocity, mode, timers), not from the client's own.
ClientReconcile
void ClientReconcile(uint32_t ackTick)GetCorrectionOffset
Vec3 GetCorrectionOffset() constClient: the visual offset still hiding the last correction.
ClientApplySmoothing
void ClientApplySmoothing(float deltaTime)BuildButtonMask
static uint16_t BuildButtonMask(bool sprint, bool crouch, bool jump)BuildButtonMask
static uint16_t BuildButtonMask(bool sprint, bool crouch, bool jump, bool jumpHeld)WriteNetMovementState
static void WriteNetMovementState(World& world, uint64_t entityId)Server: publish the pawn's movement state into its NetMovementState component (added on first use) after a move.
ReadNetMovementState
static bool ReadNetMovementState(const void* shadow, const FCharacterMoveState& local, FCharacterMoveState& out)Client: the server's movement state from the replicated shadow, with the fields the snapshot does not carry (root-motion sources) taken from local. False when nothing has arrived yet.
EncodeMoveSeconds
static uint16_t EncodeMoveSeconds(float seconds)MoveSeconds
static float MoveSeconds(const ReplicationInputBody& move)QuantizeMoveAxis
static float QuantizeMoveAxis(float value)QuantizeLookAxis
static float QuantizeLookAxis(float value)QuantizeMove
static void QuantizeMove(ReplicationInputBody& move)CanCombineMoves
static bool CanCombineMoves(const ReplicationInputBody& held, const ReplicationInputBody& next, float combinedSeconds)ClientSubmitMove
void ClientSubmitMove(const ReplicationInputBody& move, float dt, const FCharacterMoveState& state, bool combinable)ClientCapturePredictedPose
void ClientCapturePredictedPose(const Vec3& position, const FCharacterMoveState& state)ClientFlushHeldMove
void ClientFlushHeldMove()HasHeldMove
bool HasHeldMove() constGetHeldMoveSeconds
float GetHeldMoveSeconds() constGetCombinedMoveCount
uint32_t GetCombinedMoveCount() constGetSentMoveCount
uint32_t GetSentMoveCount() constGetPredictedStepCount
size_t GetPredictedStepCount() const