Esempio n. 1
0
        public void Update()
        {
            // If guard can see player, save their location
            if (sm.SeePlayer(viewDistance))
            {
                this.lastSeen = GameObject.Find("Player").transform.position;

                if (sm.SeePlayer(attackDistance))
                {
                    sm._state = GuardAI.State.StateShoot;
                }
                else
                {
                    sm.agent.SetDestination(lastSeen);
                }
            }
            else
            {
                if (sm.SimilarVector3(sm.transform.position, lastSeen))
                {
                    sm._state = GuardAI.State.StateScan;
                }
                else
                {
                    sm.agent.SetDestination(lastSeen);
                }
            }
        }
Esempio n. 2
0
        public void Update()
        {
            // If at pointA/B, reverse direction to the other
            if (sm.SimilarVector3(sm.transform.position, pointA))
            {
                this.toA = false;
            }
            if (sm.SimilarVector3(sm.transform.position, pointB))
            {
                this.toA = true;
            }

            // If guard can see player, change to StateHunt
            if (sm.SeePlayer(viewDistance))
            {
                sm._state = GuardAI.State.StateHunt;
            }

            // Move to pointA if toA else pointB
            sm.agent.SetDestination(toA ? pointA : pointB);
        }