Search Unity

Get Animator Blend Tree

Discussion in 'Scripting' started by Camronas, Sep 14, 2018.

  1. Camronas

    Camronas

    Joined:
    Apr 20, 2012
    Posts:
    154
    Just wondering, is it possible to get the Blend tree of an Animator?

    I want to play a random animation from the Blend Tree but I want the code to be as flexible as possible. Some sudo code for the concept I am looking for is:

    Code (CSharp):
    1. int rng = Random.Range(0, BlendTree.Length);
    2.  
    3. _anim.SetFloat("RandomAnimation", rng);
    Is this possible? Or do I have to set parameters for the random number directly?

    Thanks for your time!