Search Unity

Convert Script bools to blend tree

Discussion in 'Animation' started by Ziron999, Feb 21, 2017.

  1. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    How would i convert the following into a blend tree?

    Code (CSharp):
    1. if (offsetY < 20 && offsetY > -20)
    2.                     anim.SetBool("RunForward", true);
    3.                 else
    4.                     anim.SetBool("RunForward", false);
    5.                 if (offsetY < 230 && offsetY > 130)
    6.                     anim.SetBool("RunBackward", true);
    7.                 else
    8.                     anim.SetBool("RunBackward", false);
    9.                 if (offsetY >= 20 && offsetY <= 130)
    10.                     anim.SetBool("RunRight", true);
    11.                 else
    12.                     anim.SetBool("RunRight", false);
    13.                 if (offsetY >= 230 || offsetY <= -20)
    14.                     anim.SetBool("RunLeft", true);
    15.                 else
    16.                     anim.SetBool("RunLeft", false);
    it is a rotation value of y with the offset of -45 to make up = 0
     
  2. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    to be more specific i'm trying to get a top down camera going and it works with the following:
    Code (CSharp):
    1. if (Input.GetKey(KeyCode.W))
    2.                 {
    3.                     rotationYRatio = transform.rotation.eulerAngles.y / 360;
    4.                     anim.SetFloat("RotationY", rotationYRatio);
    5.                 }
    The problem is...it needs to be possible to do the other directions somehow. the blend tree works great now with w.