AActor::GetNetPriority
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Returns the replication priority for this actor on a given connection. Higher values mean the actor is replicated before lower-priority actors when bandwidth is limited.
Caveats & Gotchas
- • The default implementation multiplies NetPriority by Time and adjusts for distance/angle — override only if the default spatial heuristic is insufficient for your actor type.
- • Priority is relative, not absolute; the engine normalises and sorts all actors per connection each tick. Setting an extremely high value starves other actors.
- • bLowBandwidth hints that you should return a conservatively low value for non-critical actors to avoid saturating the connection.
Signature
ENGINE_API virtual float GetNetPriority(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& | World position of the viewer (typically the player controller's camera). | — |
| ViewDir | const FVector& | Unit direction vector the viewer is facing. | — |
| Viewer | class AActor* | The net-owning actor of the connection being prioritized for. | — |
| ViewTarget | AActor* | The actor currently viewed or controlled by Viewer. | — |
| InChannel | UActorChannel* | The replication channel for this actor. | — |
| Time | float | Seconds since this actor was last replicated. | — |
| bLowBandwidth | bool | True if the connection is currently bandwidth-constrained. | — |
Return Type
float Example
Always prioritize this actor for the owner's connection C++
float AMyImportantActor::GetNetPriority(
const FVector& ViewPos, const FVector& ViewDir,
AActor* Viewer, AActor* ViewTarget,
UActorChannel* InChannel, float Time, bool bLowBandwidth)
{
if (Viewer == GetOwner()) { return 10.f; }
return Super::GetNetPriority(ViewPos, ViewDir, Viewer, ViewTarget, InChannel, Time, bLowBandwidth);
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?