I have 8 characters, they all come from the CC3 and have similar bone structures. Only one of them has animations attached to it (51). They are characters for the background of a scene.
I want them to select a random animation from this set and play it, then select another animation and play that. All randomly, continuously. I plan on placing a lot of them to simulate a crowd.
I’ve been googling this for a few days but, maybe it’s just my search terms, but I’m not finding anything that remotely seems to help.
I’m pretty new to UE4, and very new to visual scripting (or scripting in general).
Then I create an Animation Montage that is compatible with the skeleton of the character and add all the animations that I want it to be able to chose from, put each one in it’s own section of the montage and “clear” them so they all play independently. It’s also worth noting here that blending plays into this a bit depending on your animations you may want to increase/decrease the blend time. You can create a new slot name or stick to default slot if you prefer.
I then setup the Anim Graph in the Anim BP to play the slot animation that I assigned in the montage on top of my idle so that it has a nice base pose.
Then finally in the Event Graph of the Anim BP I setup the script to run the Montage, I set it to run on Begin Play and then wait a random amount of time, to help keep it more out of sync from other characters and add some more randomness as it continues. I create an array of Names for the sections of the Montage and each time I play select a random one. When the section is finished it will run the event again wait again, and so on, and so on, in a loop.
And that’s it. I found this method worked well for me, as it was low maintenance and clean, didn’t have to update anything if I added more characters to the crowd. But there are many ways to achieve the same result, you should use whatever you think is the best solution for you.
Wish I could delete comments. So I think I’ve got it MOSTLY where you’ve got it. With the min/max do I have to input anything in the value ranges?
And with the Sections > Random - how would I set that up?
The min/max is up to you, all that dictates is the amount of time that is delayed between playing animations.
The sections->random is simply an Array of names that match the sections of the montage, in the case of that example they are simply titled 1-7 but could be called anything you wish, and the random node just pulls a random index from the array to select which one to play.
Hey Bruffhaus! Thank you so much for replying. I ended up sleeping on it and coming back the next day and it all went a lot smoother. I think I was just getting frustrated at myself.
I think I’ve got it almost exactly set up how you do, but it doesn’t actually seem to run through the animations, and I’m wondering if I have either my montage setup incorrectly or my sections variable.
My montage has lavendar coloured sections, not green. I’m not sure if this is a problem.
“PlayMontage” is a latent action (denoted by the little clock in the top right corner) the top execution pin does not wait for the latent action to complete before executing and so it would be trying to play again over the top of the existing one and restarting each time. You need to change that to only execute after it’s finished so in this case connect it to “OnCompleted” instead.
I’ve changed it and compiled it, but I still don’t get anything. It’ll play the initial animation set in the AnimGraph, but it doesn’t seem to play anything from my Montage.
I know it’s an old post but I basically do the exact same thing.
The only problem that I can’t solve is how to “blend” seamlessly between the different animation tracks in the montage, the same way we can blend two different animation tracks in the sequencer.
In my own version to things the animation just abruptly changes to the next one.