RealDocs

AActor::GetNetDormancy

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: virtualENGINE_API

Description

Determines whether this actor should be dormant for a specific net connection. Only evaluated when the actor's NetDormancy is set to DORM_DormantPartial, allowing per-connection dormancy decisions.

Caveats & Gotchas

  • This function is only called when NetDormancy == DORM_DormantPartial. For DORM_Awake or DORM_DormantAll, the engine never consults this function.
  • Returning true does not immediately close the actor channel — the actor will go dormant on the next replication pass. Any property changes that occurred before dormancy takes effect will still be sent.
  • Per-connection dormancy (DORM_DormantPartial) has higher CPU overhead than DORM_DormantAll because GetNetDormancy must be evaluated for every connection on every replication frame.

Signature

ENGINE_API virtual bool GetNetDormancy(const FVector& ViewPos, const FVector& ViewDir, class AActor* Viewer, AActor* ViewTarget, UActorChannel* InChannel, float Time, bool bLowBandwidth);

Parameters

Name Type Description Default
ViewPos const FVector& Position of the viewer in world space.
ViewDir const FVector& View direction vector of the viewer.
Viewer class AActor* Net object owned by the client for whom dormancy is being evaluated.
ViewTarget AActor* The actor currently being viewed or controlled by Viewer.
InChannel UActorChannel* The actor channel on which this actor is being replicated.
Time float Time in seconds since this actor was last replicated.
bLowBandwidth bool True if the connection is considered low bandwidth.

Return Type

bool

Example

Dormant when out of range per connection C++
bool AMyActor::GetNetDormancy(const FVector& ViewPos, const FVector& ViewDir,
	AActor* Viewer, AActor* ViewTarget, UActorChannel* InChannel, float Time, bool bLowBandwidth)
{
	// Go dormant for any viewer more than 5000 units away
	const float DistSq = FVector::DistSquared(ViewPos, GetActorLocation());
	return DistSq > FMath::Square(5000.0f);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.