Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

EmotionFX: Ability for SimpleMotionComponent & AnimGraphComponent to exist on same entity #540

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnimGraphComponentRequests>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>("AnimGraphComponentNotificationBus")
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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*/);
Expand Down