You can write a script that runs when StateA is activated and creates a randomised boolean (true / false), which you can use as a parameter in the Animator.
I'm writing this in UnityScript (.js), but it can easily be translated to C# (.cs) if needed:
#pragma strict
var useStateB : boolean;
function Start () {
useStateB = Random.value > 0.5f; //this returns 50-50 true or false
}
Then simply make a connection from StateA to StateB with "useStateB = true" and one from StateA to StateC with "useStateB = false".
Of course, using a boolean only works with two states. I you have more than two, you can use a randomised integer instead:
#pragma strict
var useState : int;
var amountOfStates : int = 3; //let's use 3 states for this example
function Start () {
useState = Random.Range(1, amountOfStates + 1); //returns 1, 2 or 3: Random.Range includes the min value, but excludes the max value => add 1 to the desired max value
}
Replies
I'm writing this in UnityScript (.js), but it can easily be translated to C# (.cs) if needed:
Then simply make a connection from StateA to StateB with "useStateB = true" and one from StateA to StateC with "useStateB = false".
Of course, using a boolean only works with two states. I you have more than two, you can use a randomised integer instead: