using UnityEngine; public class GameManager : MonoBehaviour { private bool isPolInvisible = false; private float invisibleTime = 20f; private float invisibleTimer = 0f; private void OnCollisionEnter(Collision collision) { if (collision.collider.CompareTag("Obstacle")) { Debug.Log("Конец игры (c)"); } if (collision.collider.CompareTag("SkritiePola")) { HidePolForDuration(); Debug.Log("SkrPola"); } if (collision.collider.CompareTag("NullRotation")) { ResetPlayerRotation(); Debug.Log("0Rotation"); } } private void Update() { if (isPolInvisible) { invisibleTimer += Time.deltaTime; if (invisibleTimer >= invisibleTime) { isPolInvisible = false; SetPolVisibility(true); } } } private void HidePolForDuration() { isPolInvisible = true; invisibleTimer = 0f; SetPolVisibility(false); } private void SetPolVisibility(bool isVisible) { GameObject[] polObjects = GameObject.FindGameObjectsWithTag("Pol"); foreach (GameObject polObject in polObjects) { Renderer polRenderer = polObject.GetComponent(); if (polRenderer != null) { polRenderer.enabled = isVisible; } } } private void ResetPlayerRotation() { GameObject playerObject = GameObject.FindWithTag("Player"); if (playerObject != null) { playerObject.transform.rotation = Quaternion.identity; } } }