How to randomly play one of two animations?

i need a character to play one of two animations, but grabbing it randomly.

im totally lost how to do a if statement in an anim state machine, how do u do this?

Use a RandomInt node, 0 to 1, and then an InRange node to check if it is 0. Tie the InRange to a branch, and if it is 0 it will execute true, and if not then false.

… where is this “branch” you speak of?

i would really like a switch(case) that can do one of possibly six different anims… so yeah… im lost

1 Like

Hmm, are you in the material editor? Maybe it doesn’t have the same options? Can it call functions or macros? Maybe if you create a function in your class blueprint you can do the switching there.

Yeah, I think that would be the better place to do that anyway, unless you have some specific circumstances.

Branch is under Utilities - Flow Control.

Also, In Range (Float) is the range checker and should work fine.

those flow controls are not there, and im in the animblueprint of a character class.

i found blend poses with a float alpha, there seems to be no way to do a switch case system for it.

I think the ‘Blend Poses by Int’ node will do what you are looking for. After adding the node to your state, you can rt-click it and “Add Blend Pin” to add as many input animations as you need.

Good luck!

1 Like

OMG thank YOU!!!

k this is gonna rock. :slight_smile:

The sequence variable of the play function can be promoted to (As Pin) Sequence. Create a Select to this pin. The select function got by default two options wich can be expanded ( right click ). Use an integer to select between the option. Now you only need to set this integer to a random value.

1 Like

In this solution, I’m able to use this sequence in Transition Rule? I suppose it is not possible

im having a similar problem, I feel like this could be the answer but i can t seem to make a play anim sequence that takes an input
also not 100% sure what type of pin you made the options, as theres various anim sequence choices, base and without and then reference, object etc

Look up the node called Random Sequence Player. That’s exactly what you’re looking for.

2 Likes

Thank you so much for this, way better than random integer stuff.

It’s a pretty simple solution but it worked for me

1 Like

Thank you, cool node.

This is how you expose a sequence as a pin.

Actually, there is an easier way!