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 |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| DeltaSourceBufferSize | const int32 | Size of the array caching Delta Sources for delta serialization. | 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 |
|---|---|---|---|---|
| bCompareInputToTriggerRewind | bool | Physics/NetworkPhysicsComponent.h | ||
| bCompareStateToTriggerRewind | bool | Compare state / input to trigger rewind via FNetworkPhysicsData::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 | |
| bIsRelayingLocalInputs | bool | Locally relayed inputs makes this component act as if it's a locally controlled pawn. | 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 | ||
| InputDataDefault | TUniquePtr< FNetworkPhysicsData > | Local temporary input data. | 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 | uint16 | 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.DynamicInputScaling.Enabled is enabled. | 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. | Physics/NetworkPhysicsComponent.h | |
| InputsToNetwork_Simulated | uint16 | Send last N number of inputs each replication call from server to remote clients. | Physics/NetworkPhysicsComponent.h | |
| InputsToNetworkRemote | uint16 | 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 | TUniquePtr< FNetworkPhysicsData > | Local temporary state data. | 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. | 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
(
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 | |
const float GetCurrentInputDecay
(
FNetworkPhysicsData* PhysicsData |
Returns the current amount of input decay during resimulation as a magnitude from 0.0 to 1.0. | 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() |
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 | |
virtual APlayerController * GetPlayerController() |
Get the player controller. | Physics/NetworkPhysicsComponent.h | |
TSharedPtr< Chaos::FBaseRewindHistory > & GetStateHistory() |
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 SendInputData() |
-- Deprecated API -- Replicate input data | Physics/NetworkPhysicsComponent.h | |
void SendStateData() |
Replicate state data | 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 FNetworkPhysicsData 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 FNetworkPhysicsData 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 | |
int32 SetupRewindData() |
Enable RewindData history caching and return the history size | Physics/NetworkPhysicsComponent.h | |
void StopRelayingLocalInputsDeferred () |
Stop relaying local inputs after next network send. | 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() |
Register the component into the network manager. | Physics/NetworkPhysicsComponent.h | |
virtual void TickComponent
(
float DeltaTime, |
Called every frame. | Physics/NetworkPhysicsComponent.h | |
virtual void UninitializeComponent() |
Unregister the component from the network manager. | 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 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_SetReplicatedInputs() |
Repnotify for inputs on owner client | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedRemoteInputs() |
Repnotify for inputs on remote clients | Physics/NetworkPhysicsComponent.h | |
void OnRep_SetReplicatedStates() |
Repnotify for the states on the client | Physics/NetworkPhysicsComponent.h | |
void ServerReceiveDeltaSourceInputFrame
(
const int32 Frame |
Server RPC to acknowledge which Delta Source Input Frame the owning client has received | Physics/NetworkPhysicsComponent.h |
|
void ServerReceiveDeltaSourceStateFrame
(
const int32 Frame |
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 ServerReceiveInputData
(
const FNetworkPhysicsRewindDataInputProxy& ClientInputs |
Server RPC to receive inputs 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 |