using UnityEngine;
using UnityEngine.UI; // Import this to work with UI elements
public class WinTrigger : MonoBehaviour
{
public GameObject winMessage; // Reference to the UI Text GameObject
// This method is called when another Collider2D enters the trigger area
private void OnTriggerEnter2D(Collider2D other)
{
// Check if the object that entered the trigger is the player's sprite
if (other.CompareTag("Player"))
{
// Display the win message
winMessage.SetActive(true);
}
}
using UnityEngine; using UnityEngine.UI; // Import this to work with UI elements
public class WinTrigger : MonoBehaviour { public GameObject winMessage; // Reference to the UI Text GameObject
}