Select a random animation (Metahuman)

Good afternoon,

I’m trying to make a blueprint that selects a random animation for a metahuman, and I don’t even know where to start.

I’ve seen tutorials for selecting a random animation, but they only work for the ThirdPersonBP. I also came across some tutorials that used animation montages, but neither method seems to work for metahumans. Or at least I don’t know how.

I have the animations set up through LevelSequences, and right now it’s programmed to loop the character’s idle animation. The idea is that this animation is randomly interspersed with two other animations prepared in its own level sequences.

The happy idea would be that it would work with probabilities, that is, the main animation would have an 80% probability, the second one would have a 10% probability, and the third one would have another 10%. Just like Forest, where you can choose the % probability of each type of vegetation.

Any kind of help on this is welcome and more than appreciated, either to develop this method or whichever is the most convenient.

PS: I’m working with Unreal Engine 4.27

1 Like

Well, answering my own question, but just in case someone, someday finds themselves in this same spot (I doubt it but whatever), I did the following:

Following one of my teammates ideas, I stored all my animations in an array, and then generated a random number. Each animation corresponds to a range of these numbers, as shown in the first image, and through various branches, all possible cases are covered.

Branch 1 - Animation 1, 70% of possibilities
Branch 2 - Animation 2, 20% chance.
Etc.

The animation that comes out is saved with a set in a variable and played. Finally a delay is added and the cycle is started again, having created a handmade loop (the delay is necessary, otherwise UE sees it as an infinite loop and crashes).

Hopefully it will be of some use to someone.

Regards!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.