Example #1
0
    //---------------------------------------------------
    // Sets State and Animator Controller bool true and the rest of the bools to false

    public void SetStateTo(PossibleStates stateToSet)
    {
        for (int i = 0; i < animator.parameterCount; i++)
        {
            if (animator.GetParameter(i).name == stateToSet.ToString())
            {
                animator.SetBool(stateToSet.ToString(), true);
                currentState = stateToSet;
            }

            else
            {
                // If it is a Bool then sets it to false. So it doesn't try to set the Speed Variable
                if (animator.GetParameter(i).type == AnimatorControllerParameterType.Bool)
                {
                    animator.SetBool(animator.GetParameter(i).name, false);
                }
            }
        }
    }
Example #2
0
    //---------------------------------------------------
    // Returns if it is certain state

    public bool IsState(PossibleStates stateToCheck)
    {
        return(animator.GetBool(stateToCheck.ToString()));
    }