SpawnActor use a ROLE_SimulatedProxy actor as template will be crash

FActorSpawnParameters SpawnInfo;
SpawnInfo.Template = RemoteActor; //ROLE_SimulatedProxy
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
SpawnInfo.bNoFail = true;
SpawnInfo.ObjectFlags = RF_Transient;
NewActor = GetWorld()->SpawnActor(RemoteActor->GetClass(), SpawnInfo);

there will be crash at AActor::PostSpawnInitialize, line 2746:
check(Role == ROLE_Authority);

Hey windywang,

How are you initializing your RemoteActor template? Could you provide that code as well?

in a multiplayer game, “remote player” is another player in local client

Could you please provide some additional information regarding your crash:

  • Are you getting a crash reporter window? If so, please provide your LoginID and ensure to hit Send & Close on the report.
  • Could you please provide logs from your project’s Saved->Logs folder from after the crash occurs?
  • Could you please provide your full code for this issue so we can ensure we are following your repro?


Assertion failed: Role == ROLE_Authority [File:UnrealEngine4.15\Engine\Source\Runtime\Engine\Private\Actor.cpp] [Line: 2746]

that’s because the “Template” of FActorSpawnParameters is ROLE_SimulatedProxy, and the “Role” property value is copied to the new spawned actor.
you can ask your engineer, it is very easy to understand

Hey windywang,

After further investigation, it appears this crash is occurring because you are attempting to spawn an actor on the server that is something other than ROLE_Authority. All actors on the server must be authoritative, otherwise this check will fail. As a result, I do not believe that this is a bug. I was able to replicate the crash, but it seems like intended behavior based on the current documentation and my understanding of Actor Roles: Actor Role and RemoteRole | Unreal Engine Documentation

Let me know if you have further questions or comments regarding this.

Have a great day