Search Unity

Accessing blend tree parameters

Discussion in 'Animation' started by spelafort, Feb 17, 2018.

  1. spelafort

    spelafort

    Joined:
    May 8, 2017
    Posts:
    37
    Hi, I'm having a problem changing blend tree parameters through code. I'm trying to access them through the animator itself, assuming that they were the same thing:

    Code (CSharp):
    1.         blend1 = myTankAnimator1.GetFloat("Blend");
    2.  
    3.  
    4.         float blend1New = Random.Range(0,1);
    5.  
    6.         blend1 = blend1New;
    7.  
    8.         myTankAnimator1.SetFloat("Blend", blend1);

    But reading the docs, it seems like I may need to call the blend tree itself separately and change the parameter from there (I did notice that the parameters on the side of the animator do not change when I use the blend tree sliders-- this is confusing). So I've made a public variable of type BlendTree and dropped in what I need, but I can't seem to do anything with it after typing this:

    Code (CSharp):
    1. myBlendTree.blendParameter
    There seems to be no equivalent to 'set'. How can I access/change parameters in a blend tree? Any help appreciated!