diff --git a/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp b/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp index fafaa30c4f..31884d4c94 100644 --- a/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp +++ b/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp @@ -122,6 +122,12 @@ namespace Multiplayer AZStd::vector> netEntities; GatherNetEntities(sourceInstance.get(), netEntities); + if (netEntities.empty()) + { + // No networked entities in the prefab, no need to do anything in this processor. + return; + } + // Instance container for net entities AZStd::unique_ptr networkInstance(aznew Instance()); @@ -129,12 +135,6 @@ namespace Multiplayer AZ::Data::Asset networkSpawnableAsset; networkSpawnableAsset.Create(networkSpawnable->GetId()); networkSpawnableAsset.SetAutoLoadBehavior(AZ::Data::AssetLoadBehavior::PreLoad); - - if (netEntities.empty()) - { - // No networked entities in the prefab, no need to do anything in this processor. - return; - } // Each spawnable has a root meta-data entity at position 0, so starting net indices from 1 size_t netEntitiesIndexCounter = 1;