AActor::SetNetAddressable
#include "GameFramework/Actor.h"
Access: public
Description
Marks this actor as net-addressable by its full path name so that clients can reference it by name even though it was spawned dynamically after map load. Must be called before FinishSpawning.
Caveats & Gotchas
- • The caller is responsible for ensuring the actor has a stable, deterministic name on both server and client — if names diverge (e.g. due to non-deterministic spawning order), clients will fail to resolve the actor reference and RPCs targeting it will be dropped.
- • Must be called before FinishSpawning (i.e. in the deferred spawn window between SpawnActorDeferred and FinishSpawning); calling it afterwards has no effect.
- • Only useful for dynamically spawned actors that need to be referenced by subobject path (e.g. for object-level RPCs). Statically placed actors are already net-addressable.
Signature
ENGINE_API void SetNetAddressable(); Return Type
void Example
Deferred spawn with net addressability C++
// On the server, during deferred spawn
AMyActor* Actor = GetWorld()->SpawnActorDeferred<AMyActor>(
AMyActor::StaticClass(), SpawnTransform);
if (Actor)
{
Actor->SetNetAddressable();
Actor->Rename(TEXT("MyStableActorName"));
UGameplayStatics::FinishSpawningActor(Actor, SpawnTransform);
} See Also
Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?