Dynamic blending of animation assets at runtime...

I have a crowd of skeletal mesh components created within a Blueprint at runtime.

They all share the same the skeleton and animation assets despite having different meshes.

I can assign a random dance animation with random start offset for a great degree of variety. This is all working fine.

However, what I would really love to be able to do is to blend between a random idle animation (from another array set up in the Blueprint) and a random dance animation.

So similar to a 1D Blendspace but instead of hard coding the animation assets within the Blendspace, I want to be able to blend between a random asset from the two states (idle > dance).

Using an Animation Blueprint I can blend between two Sequence Player pose inputs in the AnimGraph using an exposed float variable. This again works great, but I am still missing the ability to pass a random idle and a random dance animation asset.

I could create a bunch of Blendspaces or Montages but there would be so many combinations, I’d rather not.

I did investigate (with the help of ChatGPT) the use of Animation Layer Interfaces and Animation Layers inside an Animation Blueprint - but frankly the suggestions of the AI did not align with reality and I gave up.

Is this even possible? If so, could anyone point me in the direction of how to implement this?

Thanks in advance.

I would do something like that.

Create a standard state machine within your ABP, with Idle and Dance as states

Assign automatic rule for the transition on both

Inside each state set the Sequence Player and save the animation sequence as a variable

For each transition set a Start Event, where Idle to Dance will be called “Random Dance” and Dance to Idle will be called “Random Idle”

Then in your event graph search for both Random Dance and Random Idle events and create a logic similar to this

Store the various animations into the IdleArray and DanceArray, and every time one of the event is triggered ( meaning as soon as the state transition starts ) the random Int will choose an animation based on the array, which then set the idle/Dance animation variable.

Begin Play connected to RandomIdle is to just have a random int as soon as the AnimBP becomes active, otherwise you’ll always start with Int0 as the first animation that will play.

I haven’t tested everything but it should work as intended.

Amazing detail in the reply. Thank you.

This seems like it should work. I will test when I get a chance and get back to you.

Ok, tested that and it works as follows:

  1. As soon as the project starts, an idle animation is selected and plays

  2. As soon as the idle animation finishes, a random dance animation is selected and played

  3. When the dance animation is complete, repeat from step 1.

This is a great start as with some tweaking to the transition duration and curve, the blend between them looks acceptable.

What I really need for this project (and even with your help with the above, I am still struggling to see how to control this) is to be playing one of the idle animations at project start and keep playing that animation on loop in the Idle state UNTIL I press a button elsewhere in the project.

Then it transitions to a random dance animation and plays that on loop UNTIL a button is pressed at which point the animation blends back to the Idle state, looping until ready to be triggered again.

So what I need help with is how to trigger a state from an external Blueprint. Probably the same Blueprint where I add these skeletal meshes to the world.

Hope that makes sense?

I think the best way to do that is like this:

Set the button press where you want ( let’s say from your CharacterBP ), and set a bool ( call it StartDance or something like that ) to True.

Then inside your ABP on Event Graph, use Event Blueprint Begin Play, from TryGet PawnOwner cast to your CharacterBP and save the output as a variable ( call it PlayerPawn ).

Bu doing so you’re storing the reference to your character just on begin play.

Now get inside the Idle to Dance transition, then right click and look for PropertyAccess.
Once you have that node you need to look for your PlayerPawn reference, then from there you’ll find the boolean you previously saved ( if you’re on 5.5 and up you can use the search option at the very top of the list to make it easier to find ).

On the transition, remove the AutomaticRuleBase option and just use your boolean as the condition.

By doing so you’re ready the change in value of the boolean from your PlayerPawn reference whenever that value changes, so the idle is going to play on loop for the entire time, unless you press the button.

You can do the same thing to going back to Idle, but you also need to set the boolean ( StartDance ) to false as well, otherwise it’ll go back to the dance state again.

Thanks for this. Have stepped away from this project for the week, will pick it back up next week and give it a try!

Your suggestions led to the solution to suit my needs. Thank you!

1 Like