RealDocs

AActor::IsNetMode

function Engine Since 4.14
#include "GameFramework/Actor.h"
Access: public

Description

Returns true if the current network mode matches Mode. In shipping builds this can be more efficient than GetNetMode() because the compiler eliminates dead branches for modes impossible in that build configuration.

Caveats & Gotchas

  • In editor (PIE) builds, the optimisation is disabled and it falls back to GetNetMode() == Mode — both are equivalent there.
  • Prefer this over GetNetMode() == X in hot code paths such as Tick, especially in dedicated server or client-only builds where the compiler can eliminate entire branches.
  • IsNetMode(NM_Standalone) returns true in a single-player PIE session AND in a packaged standalone build — distinguish them with WITH_EDITOR if needed.

Signature

bool IsNetMode(ENetMode Mode) const

Parameters

Name Type Description Default
Mode ENetMode The network mode to test against.

Return Type

bool

Example

Skip expensive visual effect on dedicated server C++
void AMyActor::SpawnVisualEffect()
{
    if (IsNetMode(NM_DedicatedServer)) { return; }
    // Spawn particle effect — only on clients and listen servers
    UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionFX, GetActorLocation());
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.