[5.4] AdvancedAnimationComponent - how to handle one-off animations?

#1
In the FPS template the character's animations are evaluated every frame like this:

Code: Select all

const auto& desiredFragmentId = m_pCharacterController->IsWalking() ? m_walkFragmentId : m_idleFragmentId;
if (m_activeFragmentId != desiredFragmentId)
{
m_activeFragmentId = desiredFragmentId;
m_pAnimationComponent->QueueFragmentWithId(m_activeFragmentId);
}
But what about one-off animations that should play once before a return to a looping animation such as idling? Is there a way to detect when an animation is finished? Is there an anim listener?
Getting the duration of every such animation and blocking the looping animations on a timer seems like a janky way to do it.

The names of the queue functions implies queueing of anims, but it seems that subsequent calls actually cancel the previous animation:

Code: Select all

virtual void QueueFragmentWithId(const FragmentID& fragmentId)
{
if (m_pAnimationContext == nullptr)
{
return;
}

if (m_pActiveAction)
{
m_pActiveAction->Stop(); [b]// ??[/b]
}

const int priority = 0;
m_pActiveAction = new TAction<SAnimationContext>(priority, fragmentId);
m_pActionController->Queue(*m_pActiveAction);
}

Re: [5.4] AdvancedAnimationComponent - how to handle one-off animations?

#3
I've got a [urlhttps://github.com/CRYTEK/CRYENGINE/pull/348]pull request[/url] that adds a piece of code you might like for queuing actions.

It's basically just adding this to CAdvancedAnimation

Code: Select all

virtual void QueueAction(TAction<SAnimationContext>& pAction) { if (m_pAnimationContext == nullptr) { return; } m_pActionController->Queue(pAction); }
Then I queue up a single shot action with a higher priority than the locomotion and let mannequin handle queuing and playing it.

Re: [5.4] AdvancedAnimationComponent - how to handle one-off animations?

#4
Yep that's similar to what I ended up doing.

Code: Select all

virtual void EnqueueFragment(const FragmentID& fragmentId, const int priority, const bool override)
{
if (m_pAnimationContext == nullptr)
{
return;
}

if (m_pActiveAction && override)
{
m_pActiveAction->Stop();
}

m_pActiveAction = new TAction<SAnimationContext>(priority, fragmentId);
m_pActionController->Queue(*m_pActiveAction);
}
Although I actually copied and renamed the whole anim component because despite the function(s) being virtual I couldn't get it to build when subclassing CAdvAnims. For one you need the .cpp implementation of advanced anim which is missing in the launcher, but apart from that I was getting some odd schematyc based problems, possibly to do with the Cry namespaces.

Who is online

Users browsing this forum: No registered users and 2 guests

cron