using UnityEngine; using System.Collections; public class EchoLocation : MonoBehaviour { public float revealRadius = 10f; public float revealDuration = 0.5f; public LayerMask revealLayer; public Light echoLight; public AudioSource echoSound; void Update() { if (Input.GetKeyDown(KeyCode.E)) { StartCoroutine(Reveal()); } } IEnumerator Reveal() { // Воспроизведение звука if (echoSound != null) { echoSound.Play(); } // Включение света if (echoLight != null) { echoLight.enabled = true; } // Обнаружение объектов вокруг Collider[] objects = Physics.OverlapSphere(transform.position, revealRadius, revealLayer); foreach (Collider obj in objects) { Renderer rend = obj.GetComponent(); if (rend != null) { rend.enabled = true; } } yield return new WaitForSeconds(revealDuration); // Отключение света if (echoLight != null) { echoLight.enabled = false; } // Скрытие объектов foreach (Collider obj in objects) { Renderer rend = obj.GetComponent(); if (rend != null) { rend.enabled = false; } } } }