p.AllowDestroyNonNetworkActors
p.AllowDestroyNonNetworkActors
#Overview
name: p.AllowDestroyNonNetworkActors
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When enabled, allows Clients in Networked Games to destroy non-networked actors (AActor::Role == ROLE_None). Does not change behavior on Servers or Standalone games.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.AllowDestroyNonNetworkActors is to control whether clients in networked games are allowed to destroy non-networked actors (actors with AActor::Role == ROLE_None). This setting does not affect the behavior on servers or in standalone games.
This setting variable is primarily used in the Unreal Engine’s core gameplay and networking systems, specifically within the Engine module. It is referenced in the LevelActor.cpp file, which is part of the engine’s actor management system.
The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 1 (enabled) and can be changed at runtime through the console or configuration files.
The associated variable CVarAllowDestroyNonNetworkActors interacts directly with p.AllowDestroyNonNetworkActors. They share the same value and purpose.
Developers must be aware that this variable only affects client behavior in networked games. It does not change how servers or standalone games handle actor destruction. When disabled (set to 0), clients will not be able to destroy non-networked actors, which can help prevent potential synchronization issues or exploits in multiplayer scenarios.
Best practices when using this variable include:
- Carefully consider the implications of allowing clients to destroy non-networked actors in your game design.
- Use this setting in conjunction with proper network authority checks to maintain game integrity.
- Test your game thoroughly with both enabled and disabled states to ensure proper behavior in all scenarios.
- Document any custom logic that relies on this setting to inform other team members of its impact.
Regarding the associated variable CVarAllowDestroyNonNetworkActors:
The purpose of CVarAllowDestroyNonNetworkActors is identical to p.AllowDestroyNonNetworkActors. It is the C++ representation of the console variable used within the engine code.
This variable is used in the UWorld::DestroyActor function to determine whether a non-networked actor can be destroyed. The value is retrieved using GetValueOnAnyThread(), which allows for thread-safe access to the console variable’s value.
Developers should be aware that changes to this variable will take effect immediately, potentially altering game behavior at runtime. It’s important to consider the implications of changing this value during gameplay and ensure that it aligns with the game’s design and networking architecture.
Best practices for using CVarAllowDestroyNonNetworkActors include:
- Use the GetValueOnAnyThread() method for thread-safe access when checking the variable’s value.
- Consider caching the value if it’s frequently accessed in performance-critical sections of code.
- Be consistent in how you refer to this setting throughout your codebase, using either the console variable name (p.AllowDestroyNonNetworkActors) or the C++ variable name (CVarAllowDestroyNonNetworkActors) to avoid confusion.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:40
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAllowDestroyNonNetworkActors(
TEXT("p.AllowDestroyNonNetworkActors"),
1,
TEXT("When enabled, allows Clients in Networked Games to destroy non-networked actors (AActor::Role == ROLE_None). Does not change behavior on Servers or Standalone games.")
);
#define LINE_CHECK_TRACING 0
#Associated Variable and Callsites
This variable is associated with another variable named CVarAllowDestroyNonNetworkActors
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:39
Scope: file
Source code excerpt:
ECVF_Default);
static TAutoConsoleVariable<int32> CVarAllowDestroyNonNetworkActors(
TEXT("p.AllowDestroyNonNetworkActors"),
1,
TEXT("When enabled, allows Clients in Networked Games to destroy non-networked actors (AActor::Role == ROLE_None). Does not change behavior on Servers or Standalone games.")
);
#define LINE_CHECK_TRACING 0
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelActor.cpp:843
Scope (from outer to inner):
file
function bool UWorld::DestroyActor
Source code excerpt:
}
const bool bCanDestroyNonNetworkActor = !!CVarAllowDestroyNonNetworkActors.GetValueOnAnyThread();
if (!bIsNetworkedActor && !bCanDestroyNonNetworkActor)
{
return false;
}
if (ThisActor->DestroyNetworkActorHandled())