Example #1
0
    void Awake()
    {
        /*
         * for (int i = 0; i < patrol.Length; i++)
         * {
         *  patrol[i].y  = transform.position.y;
         * }
         */
        nav = GetComponent <NavMeshAgent>();
        if (patrol.Length > 1)
        {
            patrolIndex        = Random.Range(1, patrol.Length - 1); //just start somewhere.
            transform.position = patrol[patrolIndex - 1];            //assign it so we arent travelling randomly
            nav.SetDestination(patrol[patrolIndex]);
        }
        else
        {
            singlePointEulerRotation = transform.eulerAngles; //store current rotation for later
        }

        investigationPoint = new Vector3(-999, -999, -999); //Going off of the sheer confidence that this value won't be an investigation point?
        //watch it be, you silly man
        NULL_IP = investigationPoint;
        //TODO: may need to change that, because Vector3s are *not* nullable.
        IP  = transform.parent.GetComponentInChildren <InvestigationPoint>();
        aud = GetComponent <ObjectAudio>();
    }
Example #2
0
 public void NoiseAlert(Vector3 _investigationPoint, InvestigationPoint _IP)
 {
     //change state to investigative and begin navMeshing towards the point passed in.
     //if an investigation point already exists, just replace it, freshest sounds first!
     if (Mathf.Abs(_investigationPoint.y - transform.position.y) <= 6f)
     {
         //Debug.Log("Investigation Point " + _investigationPoint + " has reached enemy.");
         Debug.Log("Difference in Y positions: " + (_investigationPoint.y - transform.position.y));
         investigationPoint = _investigationPoint;
         if (state != 2)
         {
             aud.PlaySFX("enemyInvestigating");
             state            = 1;
             viz.CurrentColor = new Color(252f / 255f, 132f / 255f, 0);
             nav.SetDestination(investigationPoint);
         }
     }
     else
     {
         Debug.Log("Difference in Y positions: " + (_investigationPoint.y - transform.position.y));
     }
 }