Hi there, I am wanting to pause menu to pop open when i collide with the sprite tagged "Mother." I have tested and the pause menu opens with a button however I am unsure what code to write to get it to open when you collide with something. The script containing the "// what script goes here" is what I implemented and tried. Almost like a a congratulations page pops up when the character reaches the end of a level and you get the options to restart or go to the main menu.. Please let me know, or even if the question is hard to understand. Thanks in advance! Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class PauseMenu : MonoBehaviour { [SerializeField] GameObject pauseMenu; public void Pause() { pauseMenu.SetActive(true); Time.timeScale = 0.5f; } public void Resume() { pauseMenu.SetActive(false); Time.timeScale = 1f; } public void Home(int sceneID) { Time.timeScale = 1f; SceneManager.LoadScene(sceneID); } private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Mother") { //what script goes here } } }
Unless I misunderstood the question, you wrote your own answer: write the same code that's called when pressing the button.