RealDocs

AActor::IsNameStableForNetworking

function Engine Since 4.9
#include "GameFramework/Actor.h"
Access: public Specifiers: virtualENGINE_APIconstoverride

Description

Returns true if this actor's path name is stable enough to be used as a net reference across server and client. Actors that were placed in the level at design time typically qualify; dynamically spawned actors typically do not.

Caveats & Gotchas

  • Actors with a stable name are referenced by path over the network instead of by NetGUID, reducing the amount of state the server must track. Dynamically spawned actors use NetGUIDs instead.
  • An actor with a stable name must exist on both server and client with the same path (outer chain). If a level is not loaded on the client, the reference will fail to resolve.
  • Overriding this to return true on a dynamically spawned actor can cause hard-to-debug reference resolution failures on clients that don't have the same object hierarchy.

Signature

ENGINE_API virtual bool IsNameStableForNetworking() const override;

Return Type

bool

Example

Checking whether an actor reference will be sent by path C++
// Example: deciding which reference strategy to use
void AMyGameMode::LogActorNetInfo(AActor* Actor)
{
	if (Actor->IsNameStableForNetworking())
	{
		UE_LOG(LogGame, Log, TEXT("%s will be referenced by path over the network"), *Actor->GetName());
	}
	else
	{
		UE_LOG(LogGame, Log, TEXT("%s will use a NetGUID"), *Actor->GetName());
	}
}

Version History

Introduced in: 4.9

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.