diff --git a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp index beb17ed9f6..c53019a150 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp @@ -22,6 +22,9 @@ #include #include +AZ_CVAR(bool, bg_AssertNetBindOnDeactivationWithoutMarkForRemoval, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "If true, assert when a multiplayer entity is deactivated without first calling MarkForRemoval from NetworkEntityManager."); + namespace Multiplayer { void NetBindComponent::Reflect(AZ::ReflectContext* context) @@ -167,10 +170,13 @@ namespace Multiplayer void NetBindComponent::Deactivate() { - AZ_Assert( - m_needsToBeStopped == false, - "Entity (%s) appears to have been improperly deleted. Use MarkForRemoval to correctly clean up a networked entity.", - GetEntity() ? GetEntity()->GetName().c_str() : "null"); + if (bg_AssertNetBindOnDeactivationWithoutMarkForRemoval) + { + AZ_Assert( + m_needsToBeStopped == false, + "Entity (%s) appears to have been improperly deleted. Use MarkForRemoval to correctly clean up a networked entity.", + GetEntity() ? GetEntity()->GetName().c_str() : "null"); + } m_handleLocalServerRpcMessageEventHandle.Disconnect(); if (NetworkRoleHasController(m_netEntityRole)) {