Example #1
0
    private void Look()
    {
        RaycastHit hit;

        Debug.DrawRay(enemy.eyes.transform.position, enemy.eyes.forward * enemy.GetSightRange(), Color.yellow, 2f);

        if (Physics.Raycast(enemy.eyes.transform.position, enemy.eyes.forward, out hit, enemy.GetSightRange()) && hit.collider.CompareTag("Player"))
        {
            enemy.chaseTarget = hit.transform;
            ToChaseState();
        }
    }
Example #2
0
    private void Look()
    {
        RaycastHit hit;
        Vector3    enemyToTarget = enemy.chaseTarget.position - enemy.eyes.position;

        Debug.DrawRay(enemy.eyes.transform.position, enemyToTarget, Color.red, 2f);

        if (Physics.Raycast(enemy.eyes.position, enemyToTarget, out hit, enemy.GetSightRange()) && hit.collider.CompareTag("Player"))
        {
            enemy.chaseTarget = hit.transform;
        }
        else
        {
            ToTrackingState();
        }
    }