예제 #1
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //We process the things in our site.
        int visibleTargetsCount = fow.visibleTargets.Count;

        for (int i = 0; i < visibleTargetsCount; i++)
        {
            GameObject g = fow.visibleTargets[i];
            if (g.tag == "Prisioner" && g.name != "Player")
            {
                PrisionerBehaviour prisionerBehaviour = g.GetComponent <PrisionerBehaviour>();
                if (prisionerBehaviour.stateMachine.GetBool("fight"))
                {
                    animator.gameObject.GetComponent <GuardBehaviour>().targetPrisioner = g;
                    stateMachine.SetBool("hunting", true);
                }
            }
            if (g.tag == "Prisioner" && g.name == "Player")
            {
                //We check if it is in Prohibited zone
            }
        }

        if (sight_flag)
        {
            endRotation = startRotation * Quaternion.Euler(0, 45, 0);
        }
        else
        {
            endRotation = startRotation * Quaternion.Euler(0, -45, 0);
        }
        transform.rotation = Quaternion.RotateTowards(transform.rotation, endRotation, speed);
        if (Quaternion.Angle(transform.rotation, endRotation) < 10)
        {
            sight_flag = !sight_flag;
        }
    }
예제 #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)
    {
        PrisionerBehaviour g = animator.gameObject.GetComponent <PrisionerBehaviour>();

        g.agent.SetDestination(g.enemyPrisioner.GetComponent <Transform>().position);
    }