imanidukes / Misc-Games

Games created on Unity (Jordan, Imani)
0 stars 0 forks source link

Win Trigger #13

Open imanidukes opened 1 day ago

imanidukes commented 1 day ago

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);
    }
}

}