Re: Play full body Mannequin fragment in fp GAMESDK

No matter if you are inside of GameSDK or some of the templates, etc., animations are always triggered the same way. The simple answer would be: create an action and queue it.

The not so simple answer:
First of all you need to know if you want a custom action or if you can just use a default one. Basically you need a custom action if you want to do something before, while or after the animation plays. More on that later.

For now I just assume that you just want to play an animation and you have setup the code so that mannequin is already used (so it has an actioncontroller with a context and so on).
In this case you just do it like this:

// Find the FragmentID
auto idleFragmentId = pControllerDefinition->m_fragmentIDs.Find("Idle");
// Create the action
int priority = 0;
m_pIdleFragment = new TAction<SAnimationContext>(priority, idleFragmentId);
// Queue the action

This code is from the 5.3.4 FP Template. It is assumed (like mentioned), that you already have access to the controller definition and the action controller. This code can be found here on GitHub: ... ations.cpp

As you noticed, there is an Action created. So basically TAction is a helper to create an IAction. And you see that the struct SAnimationContext is used. All of these are defined inside of ICryMannequin.h ... annequin.h
Here you can take a look at these. This is helpful to see the full list of accepted parameters (a lot of them are optional).
In our example we just used a FragmentID and a priority as parameters.
This priority is important because the Queue is a Priorityqueue. This means that Actions with higher priority will always be played first.
And as you can see this Priorityqueue accepts Actions that are then executed.

All right. Lets move on. Let‘s say that now you want some more control over your action. For example you want something to happen if the animation ends (e.g. reloading the magazine after a reload animation played) or maybe you want to do something if the action is aborted (which could happen if an Action with higher priority gets queued while our Action plays).
In this case you could create your own Action and overwrite the corresponding functions.
Just inherit from TAction<SAnimationContext> and your custom class becomes an Action that can then be queued. You can even set some flags (e.g. requeue after it finished or stuff like that).
You could also directly inherit from IAction, but it is recommended to use the TAction helper.

You can find a lot of examples for this inside of GameSDK. Basically most of the files that have the word „anim“ or „action“. Here is an example (AnimActionAIStance.cpp): ... Stance.cpp

And here is the documentation page. This page descripes pretty detailed how Actions work and how you can implement your own Actions: ... w/15011601

Like I mentioned: a custom Action is just needed if you need more control. If you just want to play an animation then you can just use the code that I‘ve posted above (from the FP 5.3.4 Template).

However I‘ve got another documentation page for you. This here descripes pretty well how to implement an entitiy that uses mannequin from scratch: ... w/15014911

So here you also see how you get all of the stuff setup correctly before you can even queue Actions.

I hope that this was helpful.

- Jannis

ps.: If you follow the link to the .cpp file of the FP 5.3.4 Template then you can also see examples about sending tags to mannequin.

Who is online

Users browsing this forum: No registered users and 1 guest