AActor::PostNetReceiveRole
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtualENGINE_API
Description
Called immediately after the actor's Role is received from the server. Allows logic that depends on the replicated Role value to execute as soon as the role is authoritative.
Caveats & Gotchas
- • Role can change mid-session (e.g. when a pawn is possessed or unpossessed), so this can fire more than once on a given actor. Do not use it as a one-time initialization hook.
- • Called on clients only. The server always has authoritative roles and this is never invoked there.
- • The engine's default implementation handles notifying movement components of the role change. Always call Super::PostNetReceiveRole() before your custom logic.
Signature
ENGINE_API virtual void PostNetReceiveRole(); Return Type
void Example
Adjusting simulation mode when role changes C++
void AMyPawn::PostNetReceiveRole()
{
Super::PostNetReceiveRole();
// Enable local physics simulation only for SimulatedProxies
if (GetLocalRole() == ROLE_SimulatedProxy)
{
GetMesh()->SetSimulatePhysics(true);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?