public override NodeState Evaluate()
        {
            ai.SetColor(Color.yellow);
            float distance = Vector3.Distance(target.position, agent.transform.position);

            if (distance > 0.2f)
            {
                agent.isStopped = false;
                agent.SetDestination(target.position);
                return(NodeState.RUNNING);
            }
            else
            {
                agent.isStopped = true;
                return(NodeState.SUCCESS);
            }
        }
        public override NodeState Evaluate()
        {
            agent.isStopped = true;
            ai.SetColor(Color.green);
            Vector3    direction        = target.position - ai.transform.position;
            Vector3    currentDirection = Vector3.SmoothDamp(ai.transform.forward, direction, ref currentVelocity, smoothDamp);
            Quaternion rotation         = Quaternion.LookRotation(currentDirection, Vector3.up);

            ai.transform.rotation = rotation;
            if (ai.delayShoot > 0)
            {
                ai.delayShoot -= Time.deltaTime;
            }
            else if (ai.delayShoot <= 0)
            {
                ai.delayShoot = ai.auxDelayShoot;
                ai.ShootBullet();
            }
            return(NodeState.RUNNING);
        }
Esempio n. 3
0
        public override NodeState Evaluate()
        {
            Transform coverSpot = ai.GetBestCoverSpot();

            if (coverSpot == null)
            {
                return(NodeState.FAILURE);
            }
            ai.SetColor(Color.blue);
            float distance = Vector3.Distance(coverSpot.position, agent.transform.position);

            if (distance > 0.2f)
            {
                agent.isStopped = false;
                agent.SetDestination(coverSpot.position);
                return(NodeState.RUNNING);
            }
            else
            {
                agent.isStopped = true;
                return(NodeState.SUCCESS);
            }
        }