Module |
|
Header |
/Engine/Plugins/Runtime/NetworkPredictionExtras/Source/NetworkPredictionExtras/Public/MockNetworkSimulation.h |
Include |
#include "MockNetworkSimulation.h" |
struct FMockInputCmd
Mock Network Simulation
This provides a minimal "mock" example of using the Network Prediction system. The simulation being run by these classes is a simple accumulator that takes random numbers ([FMockInputCmd::InputValue](API\Plugins\NetworkPredictionExtras\FMockInputCmd\InputValue)) as input. There is no movement related functionality in this example. This is just meant to show the bare minimum hook ups into the system to make it easier to understand.
Highlights: FMockNetworkModel::SimulationTick The "core update" function of the simulation. UMockNetworkSimulationComponent The UE4 Actor Component that anchors the system to an actor.
Usage: You can just add a UMockNetworkSimulationComponent to any ROLE_AutonomousProxy actor yourself (Default Subobject, through blueprints, manually, etc) The console command "mns.Spawn" can be used to dynamically spawn the component on every pawn. Must be run on the server or in single process PIE.
Once spawned, there are some useful console commands that can be used. These bind to number keys by default (toggle-able via mns.BindAutomatically). [Five] "mns.DoLocalInput 1" can be used to submit random local input into the accumulator. This is how you advance the simulation. [Six] "mns.RequestMispredict 1" can be used to force a mis predict (random value added to accumulator server side). Useful for tracing through the correction/resimulate code path. [Nine] "nms.Debug.LocallyControlledPawn" toggle debug hud for the locally controlled player. [Zero] "nms.Debug.ToggleContinous" Toggles continuous vs snapshotted display of the debug hud
Notes: Everything is crammed into MockNetworkSimulation.h/.cpp. It may make sense to break the simulation and component code into separate files for more complex simulations.
Simulation State
Name | Description | ||
---|---|---|---|
|
float |
InputValue |
Name | Description | ||
---|---|---|---|
|
NetSerialize ( |
||
|
ToString ( |