Search Unity

Unity 5: Unable to set custom threshold values in BlendTree created by editor script

Discussion in 'Animation' started by Lividus, Apr 20, 2015.

  1. Lividus

    Lividus

    Joined:
    Apr 20, 2015
    Posts:
    3
    This is my code:

    Code (csharp):
    1.  
    2.   BlendTree idleBlendTree;  
    3.   AnimatorState idle = controller.CreateBlendTreeInController( "idle", out idleBlendTree, 0 );
    4.   idle.writeDefaultValues = false;  
    5.   idleBlendTree.blendParameter = "idlep";
    6.   idleBlendTree.blendType = BlendTreeType.Simple1D;
    7.   idleBlendTree.AddChild( _animationClipStore.AnimationList[0] );
    8.   idleBlendTree.AddChild( _animationClipStore.AnimationList[1] );
    9.   idleBlendTree.AddChild( _animationClipStore.AnimationList[2] );
    10.   ChildMotion[] children = idleBlendTree.children;
    11.   for( int i = 0; i < children.Length; i++ )
    12.   {
    13.   children[i].timeScale = 0.9f;
    14.   children[i].threshold = (float)(i);
    15.   }
    16.   idleBlendTree.children = children;
    17.  
    timeScale was changed, but threshold values stay defaults.
    Is there any ways to change threshold values?