Ejemplo n.º 1
0
    IEnumerator Detect()
    {
        float DetectArea = 0.5f * scaleUp;

        yield return(new WaitForSeconds(Random.Range(startWait.x, startWait.y)));

        while (true)
        {
            if (player == null || player.gameObject == null || player.GetComponent <Rigidbody>() == null)
            {
                yield break;
            }
            if (Vector3.Distance(transform.position, player.transform.position) < DetectArea)
            {
                Debug.Log("Found Player " + detectCount++ + " in Detect()");
                enemyMover.FoundPlayerPosition(player.GetComponent <Rigidbody>().position);
            }
            yield return(new WaitForSeconds(Random.Range(detectWait.x, detectWait.y)));
        }
    }