Всем привет делаю игру на юнити может кто-то подсказать как встроить лечение через 10 секунд если не получаешь урон
using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.SceneManagement;
public class PlayerManager : MonoBehaviour { public static int playerHealth; public static bool gameOver; public TextMeshProUGUI playerHealthText; public GameObject redOverlay;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class PlayerManager : MonoBehaviour
{
public static int playerHealth;
public static bool gameOver;
public TextMeshProUGUI playerHealthText;
public GameObject redOverlay;
void Start()
{
playerHealth = 100;
gameOver = false;
}
void Update()
{
playerHealthText.text = "" + playerHealth;
if (gameOver)
{
SceneManager.LoadScene("test");
}
}
public IEnumerator Damage(int damageCount)
{
playerHealth -= damageCount;
redOverlay.SetActive(true);
if (playerHealth <= 0)
{
gameOver = true;
}
yield return new WaitForSeconds(0.5f); // Assuming you want a 1-second delay
redOverlay.SetActive(false);
}
}