RealDocs

AActor::PostNetInit

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

Description

Called on the client immediately after an actor is spawned via replication and all initial replicated properties have been received. This is the client-side equivalent of BeginPlay for replicated actors.

Caveats & Gotchas

  • PostNetInit is only called once per actor lifetime, unlike PostNetReceive which fires on every property update. Use PostNetInit for one-time client initialization that depends on replicated state being ready.
  • BeginPlay will have already been called before PostNetInit on actors that have bNetStartup=true (placed-in-level actors). For dynamically spawned actors the order is: PostActorCreated → BeginPlay → PostNetInit.
  • If the actor is already in a dormant state when received by the client, PostNetInit fires after the actor wakes up, not at initial spawn time.

Signature

ENGINE_API virtual void PostNetInit();

Return Type

void

Example

Initializing client-side VFX after all replicated properties arrive C++
void AMyActor::PostNetInit()
{
	Super::PostNetInit();
	// ReplicatedTeamColor is now valid — safe to apply to materials
	if (MeshComponent)
	{
		UMaterialInstanceDynamic* MID = MeshComponent->CreateAndSetMaterialInstanceDynamic(0);
		if (MID)
		{
			MID->SetVectorParameterValue(TEXT("TeamColor"), ReplicatedTeamColor);
		}
	}
}

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.