RealDocs

UActorComponent::IsNetMode

function Engine Since 4.0
#include "Components/ActorComponent.h"
Access: public Specifiers: const

Description

Returns true if the component's world is currently running in the specified network mode. More efficient than GetNetMode() == Mode in non-editor optimised builds because it can short-circuit on compile-time server flags.

Caveats & Gotchas

  • In non-editor builds, IsNetMode(NM_DedicatedServer) resolves to the compile-time IsRunningDedicatedServer() constant, making it effectively free; GetNetMode() performs an actual call in the same case.
  • In editor builds (including PIE) both the compile-time flag and InternalGetNetMode() are consulted, so behaviour exactly matches GetNetMode() — there is no optimisation benefit in the editor.

Signature

bool IsNetMode(ENetMode Mode) const

Parameters

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

Return Type

bool

Example

Efficient dedicated server guard C++
void UMyComponent::ConditionalSpawnEffect()
{
	// Skipped on dedicated server at near-zero cost in shipping builds
	if (!IsNetMode(NM_DedicatedServer))
	{
		SpawnVisualEffect();
	}
}

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.