Updated NetworkSpawnableHolderComponent to use TransformBus instead of FindComponent. Added dependency on TransformService

Signed-off-by: pereslav <pereslav@amazon.com>
This commit is contained in:
pereslav
2021-09-22 13:29:55 +01:00
parent 35517c4e6a
commit ae2525564d
2 changed files with 11 additions and 9 deletions
@@ -24,6 +24,13 @@ namespace Multiplayer
}
}
void NetworkSpawnableHolderComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
// TransformService isn't strictly required in this component (Identity transform will be used by default)
// However we need to make sure if there's a component providing TransformService it is activated first.
dependent.push_back(AZ_CRC_CE("TransformService"));
}
NetworkSpawnableHolderComponent::NetworkSpawnableHolderComponent()
{
}
@@ -37,13 +44,7 @@ namespace Multiplayer
if(shouldSpawnNetEntities)
{
AZ::Transform rootEntityTransform = AZ::Transform::CreateIdentity();
AzFramework::TransformComponent* rootEntityTransformComponent =
GetEntity()->FindComponent<AzFramework::TransformComponent>();
if (rootEntityTransformComponent)
{
rootEntityTransform = rootEntityTransformComponent->GetWorldTM();
}
AZ::TransformBus::EventResult(rootEntityTransform, GetEntityId(), &AZ::TransformInterface::GetWorldTM);
INetworkEntityManager* networkEntityManager = GetNetworkEntityManager();
AZ_Assert(networkEntityManager != nullptr,