// StartLevelTrigger.cs using UnityEngine; using UnityEngine.SceneManagement; // Required for loading scenes public class StartLevelTrigger : MonoBehaviour { [Tooltip("The exact name of the scene file to load (e.g., 'level 1')")] public string sceneToLoad; [Tooltip("The tag of the player GameObject")] public string playerTag = "Player"; // This function is called when a 2D collider enters this trigger private void OnTriggerEnter2D(Collider2D other) { // Check if the object that entered is the player if (other.CompareTag(playerTag)) { Debug.Log("Player entered Start Trigger. Loading scene: " + sceneToLoad); // Make sure the scene name is not empty if (!string.IsNullOrEmpty(sceneToLoad)) { // Ensure time is running normally before loading a new scene Time.timeScale = 1f; SceneManager.LoadScene(sceneToLoad); } else { Debug.LogError("Scene to Load is not set in the Inspector for this trigger!"); } } } }