Animation Sharing Plugin - How do you trigger an on-demand animation once?

I’m playing with the 4.22 introduced Animation Sharing plugin and have a question specific to that plugin. I am able to let a crowd of actors play looping animations, such as idle, running forward and walking forward. Now I’d like to have certain actors play a one-off animation, which would be the use case for when an actor performs an action, for example performing a single jump, before transitioning to a looping animation.

The Animation Sharing Setup settings have a concept of on-demand animation states, which are described as “this means that we kick off a unique animation when needed”. If I understand correctly, when an actor registered to the Animation Sharing Manager enters an on-demand animation state, an animation blueprint is instanced for this actor alone. It makes sense to me that the use case for on-demand instances would be to play one-off actions. On-demand animation states have settings to “return to previous state” or “set next state”. Because of this, I would assume that when an actor must play a one-off animation, he is temporarily in that on-demand state and then automatically returns or moves into another state.

However, the user overridden function Process Actor State from Animation Sharing State Processor takes input parameters “Current State” and “On Demand State”. My question would be, is an on-demand state supposed be active in parallel to a non-on-demand state? If not, why are there separate values for Current State and On Demand State? And if they are supposed to play in parallel, how do you trigger the on-demand animation one-off, since Process Actor State’s return value sets the animation state so there seems to be only one animation channel? I appreciate input from anyone that has toyed with the Animation Sharing plugin!

it would be great to have a nice detailed tutorial, I have trouble with getting it to work…

same, I have yet to see any actual examples.

Finally I made it in my RTS game, one type of character works fine, with idle-move-run-attack-etc animations. I try to write a mini tutorial if I have time and remember how I did :slight_smile: Basically I followed the docs, and my intuitions :))) Probably I won’t use it, but could be good for a horde or something, will make more tests later…

hey man did you ever write the tutorial? I seriously need this.

I’m trying to follow the docs and my intuition the only thing confusing me is the AnimState he is saving in the Husk_BP how do I do that part cause his state is type byte is kinda confusing me can you point me to the right direction?

I drive animation state from the actor (I use custom actors instead of character class), because normally I play animation sequences from C++, thus I already had an animation state enum, and a behaviour system that handled it well. Thus this part of the transition for me was easy.

Shortly:

Create an Animation State Enum with values: idle, move, run, attack (etc.) Set it in in Animation State Processor at the Details tab. And create that function as in the docs. The Enum is converted to Int for the output, but it is fine. (As I see no C++ enums can be set, only Bp enums, so I have a C++ and a Bp enum with similar values now…)

Add this enum to your character, and create the state handling system in your character Bp or C++: e.g. check in Tick if movement is 0 then IDLE, if moving with a certain speed MOVE, over a certain speed RUN, if it is near enemy and facing it and withing weapon range, then stop movement and set its state to ATTACK.

Now if you have the character that can sets its Animation State Enum properly, you have to add all the states to your Animation Sharing Setup, in the same order as listed in the enum, or it won’t work! So add a state for each enum value, even if you do not use a few of them!

That’s all :slight_smile:

Moreover, I have created my custom version of the plugin, so I can use animation sets from Animation State Processor now not based on skeleton, but based on actual weapon of my characters, because normally I use a lot of characters having similar skeleton, but different weapon, requiring totally different animations. It works fine, my only issue is death, because sometimes death animations are played not from the beginning, when many character dies… and OnDemand does not work for me, and I also failed with unregistering and switching back to conventional animation mode, but maybe in future I can fix that…

I need your help for setting up Animation Sharing Plugin

I’m looking to test this in an RTS scenario as well, would be awesome if you could do a tut or something so I can see more clearly what you’re talking about.

Since there’s not really any good examples anywhere I suggest we open a git example project.

finally I do not use it. more headache than profit, in case of an RTS game.
easier to play anim sequences from C++, resulting in similar performance, but a slightly higher memory usage. beside having more flexibility and quality. (and I can have hero units using AnimBp for higher quality anims)
it could be good for a stupid crowd, nothing more without customizing the plugin source.