Ejemplo n.º 1
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //  Get the bin puppeteer first,
        bin_controller bin = animator.gameObject.transform.root.GetComponent <bin_controller> ();

        //Debug.Log ("Get Lid: " + bin.getLid());
        //  Then set the frame to the bin's lid variable (0-1)
        animator.Play(
            stateInfo.fullPathHash,
            -1, bin.getLid());
    }
Ejemplo n.º 2
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //
        //  Random blinking
        int blinkFrequency = 250;         //  bigger number = fewer blinks

        if (Random.Range(0, blinkFrequency) <= 1)
        {
            animator.SetTrigger("blinkTrigger");
        }

        //  chenge expression to match current mood
        //  These bins have like 8 levels of grumpy 2 neutral and 1 happy

        //if (animator != null &&
        //	animator.gameObject != null)
        //{
        bin_controller bin = animator.gameObject.transform.root.GetComponent <bin_controller> ();

        //Debug.Log ("mood: " + bin.getMood () / 11f);
        animator.Play(stateInfo.fullPathHash, -1, bin.getMood() / 11f);
        //}
    }