From 568b31cf1c5453e170f73f74b8ee00826b2d62a8 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich <43751992+amzn-jillich@users.noreply.github.com> Date: Mon, 19 Apr 2021 18:03:28 +0200 Subject: [PATCH] [LYN-2856] EMotionFX: Creating an Anim Graph snapshot crashes the Editor (#67) Cherry picking bug fix from 1.0 --- .../Components/AnimGraphComponent.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp index 44cc6304a9..9dabade61f 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp @@ -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& activeStates)