MiniGames/Assets/Scripts/SkyWalker/Skywalker_Obstacle.cs
2025-09-06 23:30:06 +05:00

36 lines
953 B
C#

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<Collider>();
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(DeathType.Spikes);
}
if (destroyOnContact)
{
Destroy(gameObject);
}
}
}
}