From 28a40fa4dfa0a9d51596042ef307b6f1e2addef7 Mon Sep 17 00:00:00 2001 From: pereslav Date: Thu, 7 Oct 2021 16:24:21 +0100 Subject: [PATCH] Added look up of the child entities when processing input to make sure the entity still exists Signed-off-by: pereslav --- .../Components/NetworkHierarchyRootComponent.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp index 89db2180a5..d62b103702 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp @@ -408,12 +408,16 @@ namespace Multiplayer if (auto* networkInput = input.FindComponentInput()) { + INetworkEntityManager* networkEntityManager = AZ::Interface::Get(); + AZ_Assert(networkEntityManager, "NetworkEntityManager must be created."); + for (NetworkInputChild& subInput : networkInput->m_childInputs) { - const ConstNetworkEntityHandle& childEntity = subInput.GetOwner(); - if (auto* localChild = childEntity.GetEntity()) + const ConstNetworkEntityHandle& childEntityFromInput = subInput.GetOwner(); + ConstNetworkEntityHandle localChildHandle = networkEntityManager->GetEntity(childEntityFromInput.GetNetEntityId()); + if (localChildHandle.Exists()) { - auto* netComp = childEntity.GetNetBindComponent(); + auto* netComp = localChildHandle.GetNetBindComponent(); AZ_Assert(netComp, "No NetBindComponent, this should be impossible"); // We do not rewind entity role changes, so make sure we are the correct role prior to processing if (netComp->HasController())