Navigation
API > API/Runtime > API/Runtime/Engine
Network physics component to add to actors or pawns that control their physic simulation through applying inputs, and should support networking through physics resimulation.
| Name | UNetworkPhysicsComponent |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Public/Physics/NetworkPhysicsComponent.h |
| Include Path | #include "Physics/NetworkPhysicsComponent.h" |
Syntax
UCLASS (BlueprintType, MinimalAPI)
class UNetworkPhysicsComponent : public UActorComponent
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UActorComponent → UNetworkPhysicsComponent
Implements Interfaces
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Physics/NetworkPhysicsComponent.h | |||
UNetworkPhysicsComponent
(
const FObjectInitializer& ObjectInitializer |
Physics/NetworkPhysicsComponent.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ActorComponent | TWeakObjectPtr< UActorComponent > | Actor component that will be used to fill the histories. | Physics/NetworkPhysicsComponent.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ActionImplementationInterface_Internal | INetworkPhysicsActionHandler_Internal * | Physics/NetworkPhysicsComponent.h | ||
| bCompareInputToTriggerRewind | bool | Physics/NetworkPhysicsComponent.h | ||
| bCompareStateToTriggerRewind | bool | Compare state / input to trigger rewind via FNetworkPhysicsPayload::CompareData. | Physics/NetworkPhysicsComponent.h | |
| bCompareStateToTriggerRewindIncludeSimProxies | bool | Physics/NetworkPhysicsComponent.h | ||
| bEnableReliableFlow | bool | Physics/NetworkPhysicsComponent.h | ||
| bEnableUnreliableFlow | bool | ToDo, retrieve from NetworkPhysicsSettingsComponent so changes at runtime gets picked up. | Physics/NetworkPhysicsComponent.h | |
| bHasPendingActionsToReplicate | bool | Physics/NetworkPhysicsComponent.h | ||
| bHasRegisteredInputState | bool | Physics/NetworkPhysicsComponent.h | ||
| bIsRelayingLocalInputs | bool | Locally relayed inputs makes this component act as if it's a locally controlled pawn. | Physics/NetworkPhysicsComponent.h | |
| bIsUsingLegacyData | bool | Physics/NetworkPhysicsComponent.h | ||
| bNeedsFullAsyncComponentUpdate | bool | Set by InitializePhysicsReplication when a NetworkPhysicsSettingsComponent was found but its internal (physics thread) data was not yet initialized, i.e. the settings component registered after us during seamless travel. | Physics/NetworkPhysicsComponent.h | |
| bStopRelayingLocalInputsDeferred | bool | If we are currently relaying inputs and will stop after next network send. | Physics/NetworkPhysicsComponent.h | |
| bValidateDataOnGameThread | bool | Physics/NetworkPhysicsComponent.h | ||
| DeltaSourceInputs | TArray< TUniquePtr< FNetworkPhysicsData > > | Array of delta sources, used as a base for delta serialization. | Physics/NetworkPhysicsComponent.h | |
| DeltaSourceStates | TArray< TUniquePtr< FNetworkPhysicsData > > | Array of delta sources, used as a base for delta serialization. | Physics/NetworkPhysicsComponent.h | |
| FNetworkPhysicsCallback | friend | Physics/NetworkPhysicsComponent.h | ||
| ImplementationInterface_External | INetworkPhysicsInputState_External * | Physics/NetworkPhysicsComponent.h | ||
| ImplementationInterface_Internal | INetworkPhysicsInputState_Internal * | Physics/NetworkPhysicsComponent.h | ||
| InputDataDefault_Legacy | TUniquePtr< FNetworkPhysicsData > | Local default input data in legacy type. | Physics/NetworkPhysicsComponent.h | |
| InputHelper | TUniquePtr< FNetworkPhysicsDataHelper > | Helper for the creation of input data and history with correct derived type. | Physics/NetworkPhysicsComponent.h | |
| InputHistory | TSharedPtr< Chaos::FBaseRewindHistory > | Inputs history on GameThread. | Physics/NetworkPhysicsComponent.h | |
| InputsToNetwork_Owner | uint16 | The number of inputs the owning client should send to the server with each RPC, replicated from the server. This is dynamically scaled based on when there are holes in the inputs buffer if np2.Resim.DynamicInputReplicationScaling.Enabled is enabled. Clamped by NetworkPhysicsComponentConstants::MaxNumberOfElementsToNetwork. | Physics/NetworkPhysicsComponent.h |
|
| InputsToNetwork_OwnerDefault | uint16 | The default value for number for InputsToNetwork_Owner, acts as the initial value and the cap when dynamically adjusting InputsToNetwork_Owner. Clamped by NetworkPhysicsComponentConstants::MaxNumberOfElementsToNetwork. | Physics/NetworkPhysicsComponent.h | |
| InputsToNetwork_Simulated | uint16 | Send last N number of inputs each replication call from server to remote clients. Clamped by NetworkPhysicsComponentConstants::MaxNumberOfElementsToNetwork. | Physics/NetworkPhysicsComponent.h | |
| LatestAcknowledgedDeltaSourceInputIndex | int32 | Physics/NetworkPhysicsComponent.h | ||
| LatestAcknowledgedDeltaSourceStateIndex | int32 | Physics/NetworkPhysicsComponent.h | ||
| LatestCachedDeltaSourceInputIndex | int32 | Physics/NetworkPhysicsComponent.h | ||
| LatestCachedDeltaSourceStateIndex | int32 | Physics/NetworkPhysicsComponent.h | ||
| NetworkPhysicsComponent_Internal | FAsyncNetworkPhysicsComponent * | Network Physics Component data internal to the physics thread. | Physics/NetworkPhysicsComponent.h | |
| PhysicsObject | Chaos::FConstPhysicsObjectHandle | Root components physics object. | Physics/NetworkPhysicsComponent.h | |
| StateDataDefault_Legacy | TUniquePtr< FNetworkPhysicsData > | Local default state data in legacy type. | Physics/NetworkPhysicsComponent.h | |
| StateHelper | TUniquePtr< FNetworkPhysicsDataHelper > | Helper for the creation of state data and history with correct derived type. | Physics/NetworkPhysicsComponent.h | |
| StateHistory | TSharedPtr< Chaos::FBaseRewindHistory > | States history on GameThread. | Physics/NetworkPhysicsComponent.h | |
| StatesToNetwork | uint16 | Send last N number of states each replication call from server to remote clients. Clamped by NetworkPhysicsComponentConstants::MaxNumberOfElementsToNetwork. | Physics/NetworkPhysicsComponent.h | |
| TimeToSyncDeltaSourceInput | double | Physics/NetworkPhysicsComponent.h | ||
| TimeToSyncDeltaSourceState | double | Physics/NetworkPhysicsComponent.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddDataHistory() |
Add state/input history to rewind data. | Physics/NetworkPhysicsComponent.h | |
void CreateDataHistory
(
TNetworkPhysicsInputState_Internal< Input, State >* Implementation_Internal, |
Register state and input to be networked and cached in history along with the interface implementation to interact with the input and state | Physics/NetworkPhysicsComponent.h | |
void CreateDataHistory
(
UActorComponent* HistoryComponent |
Register and create both state and input to be both networked and cached in history | Physics/NetworkPhysicsComponent.h | |
void CreateInputHistory
(
UActorComponent* HistoryComponent |
Register and create input history Please use CreateDataHistory() if both input and custom state are supposed to be networked and cached in history. | Physics/NetworkPhysicsComponent.h | |
void EnqueueImmediateAction_External
(
TActionType& Action, |
Enqueue an action based on FNetworkPhysicsActionPayload, to be executed as soon as possible. | Physics/NetworkPhysicsComponent.h | |
void EnqueueImmediateAction_External
(
TActionType& Action, |
Enqueue an action based on FNetworkPhysicsActionPayload, to be executed as soon as possible. | Physics/NetworkPhysicsComponent.h | |
void EnqueueImmediateActionInstance_External
(
TInstancedStruct< FNetworkPhysicsActionPayload >&& ActionInstance, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed as soon as possible. | Physics/NetworkPhysicsComponent.h | |
void EnqueueImmediateActionInstance_External
(
TInstancedStruct< FNetworkPhysicsActionPayload >&& ActionInstance, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed as soon as possible. | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledAction_External
(
TActionType& Action, |
Enqueue an action based on FNetworkPhysicsActionPayload, to be executed after a delay of | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledAction_External
(
TActionType& Action, |
Enqueue an action based on FNetworkPhysicsActionPayload, to be executed after a delay of | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledActionAtFrame_External
(
TActionType& Action, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed at | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledActionAtFrame_External
(
TActionType& Action, |
Enqueue an action based on FNetworkPhysicsActionPayload, to be executed at | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledActionInstance_External
(
TInstancedStruct< FNetworkPhysicsActionPayload >&& ActionInstance, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed after a delay of | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledActionInstance_External
(
TInstancedStruct< FNetworkPhysicsActionPayload >&& ActionInstance, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed after a delay of | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledActionInstanceAtFrame_External
(
TInstancedStruct< FNetworkPhysicsActionPayload >&& ActionInstance, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed at | Physics/NetworkPhysicsComponent.h | |
void EnqueueScheduledActionInstanceAtFrame_External
(
TInstancedStruct< FNetworkPhysicsActionPayload >&& ActionInstance, |
Enqueue a TInstancedStruct with an action based on FNetworkPhysicsActionPayload, to be executed at | Physics/NetworkPhysicsComponent.h | |
FNetworkPhysicsData * GetDeltaSourceInput
(
const int32 Value, |
Get the delta source stored at index or with frame, | Physics/NetworkPhysicsComponent.h | |
FNetworkPhysicsData * GetDeltaSourceState
(
const int32 Value, |
Get the delta source stored at index or with frame, | Physics/NetworkPhysicsComponent.h | |
TSharedPtr< Chaos::FBaseRewindHistory > & GetInputHistory_External() |
Get the GameThread input history (not guaranteed to be the exact data used in physics, for that use GetInputHistory_Internal on PhysicsThread) | Physics/NetworkPhysicsComponent.h | |
TSharedPtr< Chaos::FBaseRewindHistory > & GetInputHistory_Internal() |
Get the PhysicsThread input history (if there is none it returns the GameThread history) | Physics/NetworkPhysicsComponent.h | |
const bool GetIsRelayingLocalInputs () |
Check if this is controlled locally through relayed inputs from autonomous proxy. | Physics/NetworkPhysicsComponent.h | |
FAsyncNetworkPhysicsComponent * GetNetworkPhysicsComponent_Internal() |
Get FAsyncNetworkPhysicsComponent on the Physics Thread | Physics/NetworkPhysicsComponent.h | |
TSharedPtr< Chaos::FBaseRewindHistory > & GetStateHistory_External() |
Get the GameThread state history (not guaranteed to be the exact data used in physics, for that use GetStateHistory_Internal on PhysicsThread) | Physics/NetworkPhysicsComponent.h | |
TSharedPtr< Chaos::FBaseRewindHistory > & GetStateHistory_Internal() |
Get the PhysicsThread state history (if there is none it returns the GameThread history) | Physics/NetworkPhysicsComponent.h | |
bool HasServerWorld() |
Check if the world is on server. | Physics/NetworkPhysicsComponent.h | |
void InitPhysics() |
Init the network physics component. | Physics/NetworkPhysicsComponent.h | |
bool IsLocallyControlled() |
Check if this is controlled locally through relayed inputs or an existing local player controller. | Physics/NetworkPhysicsComponent.h | |
bool IsNetworkPhysicsTickOffsetAssigned() |
Check if networked physics is setup with a synchronized physics tick offset. | Physics/NetworkPhysicsComponent.h | |
void RemoveDataHistory() |
Remove state/input history from rewind data. | Physics/NetworkPhysicsComponent.h | |
void SetActionHandler
(
INetworkPhysicsActionHandler_Internal* InActionHandler |
Set action handler interface for receiving and applying actions on the physics thread. | Physics/NetworkPhysicsComponent.h | |
void SetCompareInputToTriggerRewind
(
const bool bInCompareInputToTriggerRewind |
Override the initial value set by CVar np2.Resim.CompareInputToTriggerRewind on initialize When true, compare autonomous proxies predicted FNetworkPhysicsPayload inputs with incoming server inputs to trigger resimulations if they differ, comparison done through FNetworkPhysicsData::CompareData. | Physics/NetworkPhysicsComponent.h | |
void SetCompareStateToTriggerRewind
(
const bool bInCompareStateToTriggerRewind, |
Override the initial value set by CVar np2.Resim.CompareStateToTriggerRewind on initialize When true, cache the clients FNetworkPhysicsPayload state in rewind history for autonomous proxies and compare the predicted state with incoming server state to trigger resimulations if they differ, comparison done through FNetworkPhysicsData::CompareData. | Physics/NetworkPhysicsComponent.h | |
void SetIsRelayingLocalInputs
(
bool bInRelayingLocalInputs |
Mark this as controlled through locally relayed inputs rather than controlled as a pawn through a player controller. | Physics/NetworkPhysicsComponent.h | |
void SetPhysicsObject
(
Chaos::FConstPhysicsObjectHandle InPhysicsObject |
Set the physics object that gets affected by this NetworkPhysicsComponents inputs / states, default is the physics object from the root primitive component. | Physics/NetworkPhysicsComponent.h | |
void StopRelayingLocalInputsDeferred () |
Stop relaying local inputs after next network send. | Physics/NetworkPhysicsComponent.h |
Public Virtual
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual AController * GetController() |
Get the controller for this pawn. | Physics/NetworkPhysicsComponent.h | |
virtual APlayerController * GetPlayerController() |
Get the player controller. | Physics/NetworkPhysicsComponent.h |
Overridden from UActorComponent
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void BeginPlay() |
Used to create any physics engine information for this component. | Physics/NetworkPhysicsComponent.h | |
virtual void InitializeComponent () |
Called after all sibling components have registered, ensuring NetworkPhysicsSettingsComponent data is available. | Physics/NetworkPhysicsComponent.h | |
virtual void OnRegister () |
Register the component into the network manager. | Physics/NetworkPhysicsComponent.h | |
virtual void OnUnregister() |
Unregister the component from the network manager. | Physics/NetworkPhysicsComponent.h | |
virtual void PreReplication
(
IRepChangedPropertyTracker& ChangedPropertyTracker |
Function called just before replication, alter the active state of replicated properties. | Physics/NetworkPhysicsComponent.h | |
virtual void TickComponent
(
float DeltaTime, |
Called every frame. | Physics/NetworkPhysicsComponent.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void GetLifetimeReplicatedProps
(
TArray< FLifetimeProperty >& OutLifeTimeProps |
Function to init the replicated properties. | Physics/NetworkPhysicsComponent.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void MulticastReceiveImportantInputData
(
const FNetworkPhysicsRewindDataImportantInputProxy& ServerInputs |
Client RPC to receive important inputs from server. | Physics/NetworkPhysicsComponent.h |
|
void MulticastReceiveImportantStateData
(
const FNetworkPhysicsRewindDataImportantStateProxy& ServerStates |
Client RPC to receive important states from server. | Physics/NetworkPhysicsComponent.h |
|
void MulticastReceiveReliableActionCollection
(
const FNetworkPhysicsActionCollection& ServerActionCollection |
Client RPC to receive reliable actions from server. | Physics/NetworkPhysicsComponent.h |
|
void OnRep_SetReplicatedActionsCollection() |
Repnotify for actions on the client | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedDeltaSourceInput() |
Repnotify for input, used for delta serialization | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedDeltaSourceState() |
Repnotify for state, used for delta serialization | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedInputCollection() |
Repnotify for inputs on owner client | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedOwnerInputs() |
Repnotify for inputs on owner client | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedRemoteInputCollection() |
Repnotify for inputs on remote clients | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedRemoteInputs() |
Repnotify for inputs on remote clients | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedStateCollection() |
Repnotify for the states on the client | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedStates() |
Repnotify for the states on the client | Physics/NetworkPhysicsComponent.h | |
void ServerReceiveDeltaSourceInputFrame
(
const uint32 Index, |
Server RPC to acknowledge which Delta Source Input Frame the owning client has received | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveDeltaSourceStateFrame
(
const uint32 Index, |
Server RPC to acknowledge which Delta Source State Frame the owning client has received | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveImportantInputData
(
const FNetworkPhysicsRewindDataImportantInputProxy& ClientInputs |
Server RPC to receive important inputs from client. | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveInputCollection
(
const FNetworkPhysicsDataCollection& ClientInputCollection |
Server RPC to receive inputs from client. | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveInputData
(
const FNetworkPhysicsRewindDataInputProxy& ClientInputs |
Server RPC to receive inputs from client. | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveReliableActionCollection
(
const FNetworkPhysicsActionCollection& ClientActionCollection |
Server RPC to receive reliable actions from client. | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveUnreliableActionCollection
(
const FNetworkPhysicsActionCollection& ClientActionCollection |
Server RPC to receive unreliable actions from client. | Physics/NetworkPhysicsComponent.h |
|
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static const int32 GetDeltaSourceIndexForFrame
(
const int32 Frame |
Convert frame number to its corresponding index it would hold in the delta sources array | Physics/NetworkPhysicsComponent.h |