diff --git a/dev/Gems/EMotionFX/Code/Include/Integration/AnimGraphComponentBus.h b/dev/Gems/EMotionFX/Code/Include/Integration/AnimGraphComponentBus.h index 32926c1b02..48b401d6e0 100644 --- a/dev/Gems/EMotionFX/Code/Include/Integration/AnimGraphComponentBus.h +++ b/dev/Gems/EMotionFX/Code/Include/Integration/AnimGraphComponentBus.h @@ -195,6 +195,12 @@ namespace EMotionFX /// Making a request to desync from the anim graph to its leader graph /// \param leaderEntityId - the entity id of another anim graph. virtual void DesyncAnimGraph(AZ::EntityId leaderEntityId) = 0; + + /// Starts updating an anim graph instance + virtual void StartAnimGraph() = 0; + + /// Stops updating an anim graph instance and resets its state + virtual void StopAnimGraph() = 0; }; using AnimGraphComponentRequestBus = AZ::EBus; diff --git a/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp b/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp index 8fd717cfe7..f64b199955 100644 --- a/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp +++ b/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp @@ -139,6 +139,9 @@ namespace EMotionFX // Anim Graph Sync ->Event("SyncAnimGraph", &AnimGraphComponentRequestBus::Events::SyncAnimGraph) ->Event("DesyncAnimGraph", &AnimGraphComponentRequestBus::Events::DesyncAnimGraph) + + ->Event("StartAnimGraph", &AnimGraphComponentRequestBus::Events::StartAnimGraph) + ->Event("StopAnimGraph", &AnimGraphComponentRequestBus::Events::StopAnimGraph) ; behaviorContext->EBus("AnimGraphComponentNotificationBus") @@ -1175,5 +1178,29 @@ namespace EMotionFX m_animGraphInstance.get()); } } + + void AnimGraphComponent::StartAnimGraph() + { + if (m_animGraphInstance) + { + if (m_actorInstance) + { + m_actorInstance->SetAnimGraphInstance(m_animGraphInstance.get()); + } + m_animGraphInstance->Start(); + } + } + + void AnimGraphComponent::StopAnimGraph() + { + if (m_animGraphInstance) + { + m_animGraphInstance->Stop(); + if (m_actorInstance) + { + m_actorInstance->SetAnimGraphInstance(nullptr); + } + } + } } // namespace Integration } // namespace EMotionFXAnimation diff --git a/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.h b/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.h index 772c5b9785..0a1b6e0ba6 100644 --- a/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.h +++ b/dev/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.h @@ -140,6 +140,8 @@ namespace EMotionFX bool GetVisualizeEnabled() override; void SyncAnimGraph(AZ::EntityId leaderEntityId) override; void DesyncAnimGraph(AZ::EntityId leaderEntityId) override; + void StartAnimGraph() override; + void StopAnimGraph() override; ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -174,7 +176,6 @@ namespace EMotionFX static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) { incompatible.push_back(AZ_CRC("EMotionFXAnimGraphService", 0x9ec3c819)); - incompatible.push_back(AZ_CRC("EMotionFXSimpleMotionService", 0xea7a05d8)); } static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) diff --git a/dev/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h b/dev/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h index 6a09f21b1f..1b04d19894 100644 --- a/dev/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h +++ b/dev/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h @@ -84,7 +84,6 @@ namespace EMotionFX } static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) { - incompatible.push_back(AZ_CRC("EMotionFXAnimGraphService", 0x9ec3c819)); incompatible.push_back(AZ_CRC("EMotionFXSimpleMotionService", 0xea7a05d8)); } static void Reflect(AZ::ReflectContext* /*context*/);