[LYN-2856] EMotionFX: Creating an Anim Graph snapshot crashes the Editor (#67)

Cherry picking bug fix from 1.0
This commit is contained in:
Benjamin Jillich
2021-04-19 18:03:28 +02:00
committed by GitHub
parent 4c2260af97
commit 568b31cf1c
@@ -346,13 +346,20 @@ namespace EMotionFX
void AnimGraphComponent::CreateSnapshot(bool isAuthoritative)
{
AZ_Error("EMotionFX", m_animGraphInstance, "Call create snapshot function only when anim graph is ready in this component.");
m_animGraphInstance->CreateSnapshot(isAuthoritative);
m_animGraphInstance->OnNetworkConnected();
if (m_animGraphInstance)
{
m_animGraphInstance->CreateSnapshot(isAuthoritative);
m_animGraphInstance->OnNetworkConnected();
// This will stop the MCore Job schedule update the actor instance and anim graph for authoritative entity.
// After doing so, we will have to update this actor manuelly in the networking update.
m_animGraphInstance->GetActorInstance()->SetIsEnabled(!isAuthoritative);
// This will stop the MCore Job schedule update the actor instance and anim graph for authoritative entity.
// After doing so, we will have to update this actor manually in the networking update.
m_animGraphInstance->GetActorInstance()->SetIsEnabled(!isAuthoritative);
}
else
{
AZ_Error("EMotionFX", false, "Cannot create snapshot as anim graph instance has not been created yet. "
"Please make sure you selected an anim graph in the anim graph component.");
}
}
void AnimGraphComponent::SetActiveStates(const AZStd::vector<AZ::u32>& activeStates)