using UnityEngine; [RequireComponent(typeof(Collider))] public class Skywalker_Obstacle : MonoBehaviour { [Header("Obstacle Settings")] public bool destroyOnContact = false; // if true, obstacle is removed after hit private void Reset() { // Make sure obstacle collider is set properly Collider col = GetComponent(); if (col != null) col.isTrigger = true; // obstacle works as trigger zone } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { Debug.Log("Player hit an obstacle!"); // Trigger game over through GameManager if (Skywalker_GameManager.Instance != null) { Skywalker_GameManager.Instance.TriggerGameOver(); } if (destroyOnContact) { Destroy(gameObject); } } } }