Search Unity

Question Changing a Blend Tree node's speed via editor script

Discussion in 'Animation' started by hypnoslave, Dec 19, 2022.

  1. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    439
    Hi there, I'm currently working on an editor script to automate the building of some Animator stuff. I've been constructing blend trees using:

    BlendTree.AddChild()

    and then attempting to alter the speed of some of the children using:

    BlendTree.children[3].timeScale = -1;

    ...unfotunately that does not work. I think it's because the documentation mentions that BlendTree.Children returns a copy of the list of the BlendTree's children (??) Any idea how I would actually do this?

    Thanks in advance!
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    The usual pattern is:
    Code (CSharp):
    1. var children = blendTree.children;
    2. // modify children.
    3. blendTree.children = children;
     
  3. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    439
    ah. that whole thing. of course!

    Thanks very much :)