UNetworkPredictionComponent

[UNetworkPredictionComponent](API\Plugins\NetworkPrediction\UNetworkPredictionComponent) This is the base component for running a [TNetworkedSimulationModel](API\Plugins\NetworkPrediction\TNetworkedSimulationModel) through an actor component.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

NetworkPrediction

Header

/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Public/NetworkPredictionComponent.h

Include

#include "NetworkPredictionComponent.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)(Abstract)
class UNetworkPredictionComponent : public UActorComponent

Remarks

UNetworkPredictionComponent This is the base component for running a TNetworkedSimulationModel through an actor component. This contains the boiler plate hooks into getting the system initialized and plugged into the UE4 replication system.

This is an abstract component and cannot function on its own. It must be subclassed and InstantiateNetworkedSimulation must be implemented. Ticking and RPC sending will be handled automatically, but the subclass will need to supply input to the simulation (via TNetworkedSimulationModelDriver::ProduceInput).

Its also worth pointing out that nothing about being a UActorComponent is essential here. All that this component does could be done within an AActor itself. An actor component makes sense for flexible/reusable code provided by the plugin. But there is nothing stopping you from copying this directly into an actor if you had reason to.

Variables

Name Description

Protected variable

TUniquePtr< INe...

 

NetSimModel

The Network sim that this component is managing. This is what is doing all the work.

Protected variable

ENetRole

 

OwnerCachedNetRole

Protected variable UProperty

FReplicationPro...

 

ReplicationProxy_ServerRPC

ReplicationProxies are just pointers to the data/NetSerialize functions within the NetworkSim.

Protected variable

FDelegateHandle

 

ServerRPCHandle

Constructors

Functions

Name Description

Protected function

bool

 

CheckOwnerRoleChange()

Helper: Checks if the owner's role has changed and calls InitializeForNetworkRole if necessary.

Public function Const

INetworkedSi...

 

GetNetworkSimulation()

Protected function Virtual

FNetworkSimu...

 

GetSimulationInitParameters

(
    ENetRole Role
)

Doesn't need to be overridden. Expected to be used in ::InitializeForNetworkRole implementation.

Protected function Virtual

void

 

InitializeForNetworkRole

(
    ENetRole Role
)

Finalizes initialization when NetworkRole changes. Does not need to be overridden.

Protected function Virtual

INetworkedSi...

 

InstantiateNetworkedSimulation()

Classes must instantiate their own NetworkSim here. The UNetworkPredictionComponent will manage its lifetime.

Protected function Virtual

bool

 

IsLocallyControlled()

Attempts to determine if the component is locally controlled or not, meaning we expect input cmds to be generated locally (and hence need to prepare the input buffer for that)

Public function Virtual

void

 

Reconcile()

Protected function

void

 

RegisterServerRPCDelegate()

Protected function UFunction Server, Unreliable withvalidation

void

 

ServerRecieveClientInput

(
    const FServerReplicationRPCParamete...
)

The actual ServerRPC. This needs to be a UFUNCTION but is generic and not dependent on the simulation instance.

Protected function

void

 

TickServerRPC

(
    float DeltaSeconds
)

Called via ServerRPCDelegate, ticks serverRPC timing and decides whether to send the RPC or not.

Public function Virtual

void

 

TickSimulation

(
    float DeltaTimeSeconds
)

Protected function

void

 

UnregisterServerRPCDelegate()

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

InitializeComponent()

Initializes the component.

Public function Virtual

void

 

PreReplication

(
    IRepChangedPropertyTracker& Change...
)

Called on the component right before replication occurs

Public function Virtual

void

 

TickComponent

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorComponentTickFunction* T...
)

Function called every frame on this ActorComponent.

Public function Virtual

void

 

UninitializeComponent()

Handle this component being Uninitialized.

Overridden from UObject

Name Description

Public function Virtual

void

 

PreNetReceive()

Called right before receiving a bunch

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss