UNetworkPredictionComponent

[UNetworkPredictionComponent](API\Plugins\NetworkPrediction\UNetworkPredictionComponent) This is the base component for running a 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 InitializeNetworkPredictionProxy must be implemented. Ticking and RPC sending will be handled automatically.

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 UProperty Transient, Replicated

FNetworkPredict...

 

NetworkPredictionProxy

Proxy to interface with the NetworkPrediction system.

Protected variable UProperty

FReplicationPro...

 

ReplicationProxy_ServerRPC

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

Constructors

Functions

Name Description

Public function

void

 

CallServerRPC()

Invoke the ServerRPC, called from UNetworkPredictionWorldManager via the TServerRPCService.

Protected function

bool

 

CheckOwnerRoleChange()

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

Protected function

FReplication...

 

GetReplicationProxies()

Protected function Virtual

void

 

InitializeForNetworkRole

(
    ENetRole Role,
    const bool bHasNetConnection
)

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

Protected function Virtual

void

 

InitializeNetworkPredictionProxy()

Classes must initialize the NetworkPredictionProxy (register with the NetworkPredictionSystem) here. EndPlay will unregister.

Protected function UFunction Server, Unreliable withvalidation

void

 

ServerReceiveClientInput

(
    const FServerReplicationRPCParamete...
)

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

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

EndPlay

(
    const EEndPlayReason::Type EndPlayR...
)

Ends gameplay for this component.

Public function Virtual

void

 

InitializeComponent()

Initializes the component.

Public function Virtual

void

 

PreReplication

(
    IRepChangedPropertyTracker& Change...
)

Called on the component right before replication occurs

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