AActor::GetNetDriver
#include "GameFramework/Actor.h"
Access: public
Specifiers: ENGINE_APIconst
Description
Returns the UNetDriver this actor is bound to, or nullptr if the actor has no net driver association. Used internally by the replication system.
Caveats & Gotchas
- • Returns nullptr for actors that are not networked or whose world has no net driver — always null-check before using the result.
- • Actors can be bound to non-default net drivers (e.g. a demo recorder driver or a beacon driver) via the NetDriverName property; GetNetDriver() respects this and may not return the game's primary net driver.
- • Do not cache the returned pointer across frames — net drivers can be destroyed and recreated during seamless travel.
Signature
ENGINE_API class UNetDriver* GetNetDriver() const Return Type
class UNetDriver* Example
Check if the actor has an active net driver C++
UNetDriver* NetDriver = MyActor->GetNetDriver();
if (NetDriver && NetDriver->IsServer())
{
// We are on the authority side of this net driver
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?