示例#1
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    // This script will handle the timing only and will rely on the experiment controller to handle the
    // Gaze and Player collision data.
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ExperimentController exp = ExperimentController.instance;

        // Just Started
        if (exp.IsRunning && !wasRunning)
        {
            animator.SetTrigger("Run");
            wasRunning = true;
            return;
        }
        // Just Stopped
        else if (!exp.IsRunning && wasRunning)
        {
            animator.SetTrigger("Stop");
            wasRunning = false;
            return;
        }
        // Check for state completion
        else if (exp.IsRunning && wasRunning)
        {
            if (exp.IsTrialOver())
            {
                animator.SetTrigger("TrialOver");
                return;
            }

            if (exp.IsStateOver())
            {
                animator.SetTrigger("StateOver");
                return;
            }
        }
        else
        {
            //animator.SetBool("IsTrialOver", true);
            return;
        }
    }