/*SEEING METHOD*/ public void Seeing() { RaycastHit2D hit = DrawRaycast(); if (hit.collider != null) // The enemy saw something in the player layer (Must be the player) { state = GroundEnemyState.ATTACKING; // Starts attacking } else if (state == GroundEnemyState.ATTACKING) { state = GroundEnemyState.WAITING; } }
/*LISTENING METHOD*/ public void Listening() { detectorResult = Physics2D.OverlapCircle(transform.position, detectionRadius, layerMask); // If the player is inside of the 5 radius circle he will be detected by the enemy // Gizmos.DrawSphere(transform.position, detectionRadius); // Debug listening area if (detectorResult != null && state != GroundEnemyState.ATTACKING) // The Enemy heared something and is not attacking { state = GroundEnemyState.WAITING; // Is waiting for the sound source to approach } else if (state == GroundEnemyState.WAITING) { state = GroundEnemyState.MOVING; } }