RealDocs

AActor::CopyRemoteRoleFrom

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

Description

Copies the RemoteRole from another actor and registers this actor with the net driver if the copied role makes it a networked actor. Used internally when replacing actors (e.g. pawn swap during possession).

Caveats & Gotchas

  • This function is engine-internal and intended for actor replacement scenarios such as pawn possession handoff — calling it arbitrarily can corrupt the net driver's actor registration list if the RemoteRole value is not consistent with the actor's replication setup.
  • It does not copy LocalRole (Role) — only RemoteRole is transferred, so if you need full role parity between two actors you must also handle SetAutonomousProxy() or equivalent.
  • If CopyFromActor is null or not yet registered with a net driver, the function is a no-op.

Signature

ENGINE_API void CopyRemoteRoleFrom(const AActor* CopyFromActor);

Parameters

Name Type Description Default
CopyFromActor const AActor* The actor whose RemoteRole value will be copied.

Return Type

void

Example

Transfer net role when swapping pawns C++
void AMyGameMode::SwapPawn(APawn* OldPawn, APawn* NewPawn)
{
    NewPawn->CopyRemoteRoleFrom(OldPawn);
    // Then proceed with controller reassignment
    if (AController* C = OldPawn->GetController())
    {
        C->Possess(NewPawn);
    }
}

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.