using UnityEngine; public class Skywalker_GameManager : MonoBehaviour { public static Skywalker_GameManager Instance; // Singleton [Header("UI References")] public GameObject gameOverPanel; [Header("Player Reference")] public Skywalker_PlayerController player; // assign in inspector private bool isGameOver = false; void Awake() { if (Instance == null) Instance = this; else Destroy(gameObject); if (gameOverPanel != null) gameOverPanel.SetActive(false); // hide at start } /// /// Call this to trigger jump + fall + game over UI. /// public void TriggerGameOver() { if (isGameOver) return; isGameOver = true; if (player != null) { // Force a jump first player.ForceJumpForGameOver(); // Disable collider after short delay so the fall feels natural Collider col = player.GetComponent(); Rigidbody rb = player.GetComponent(); if (col != null && rb != null) { col.enabled = false; rb.useGravity = true; } } GameoverInvoker(); // Show panel Debug.Log("GAME OVER!"); } public void GameoverInvoker() { Invoke(nameof(GameoverPanelEnabler), 1.5f); } public void GameoverPanelEnabler() { if (gameOverPanel != null) gameOverPanel.SetActive(true); } }