0
\$\begingroup\$

I have followed a tutorial to implement a pause screen for my platformer game. I followed it thoroughly but could not get it working. When I press the escape button which I assigned under the project manager under the name "Pause", it just doesn't do anything. I checked with the Scene view as well, nothing appears. Any help would be appreciated.

Edit: The script is a component of the Main Camera, not the Canvas or the PauseUI itself.

 public GameObject PauseUI;

 private bool paused = false;

void Start()
{
    PauseUI.SetActive(false);
}

void Update()
{
   if(Input.GetButtonDown("Pause"))
   {
       paused = !paused;
   }

   if(paused)
   {
       PauseUI.SetActive(true);
       Time.timeScale = 0;
   }

   if(!paused)
   {
       PauseUI.SetActive(false);
       Time.timeScale = 1;
   }
}

enter image description here

enter image description here

enter image description here

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Yeah I thought it was the same script. Can you show as well how you set up the "Pause" on the InputManager? \$\endgroup\$
    – Zibelas
    Sep 9, 2020 at 11:32
  • \$\begingroup\$ @Zibelas added another picture showing the input manager. \$\endgroup\$ Sep 9, 2020 at 11:34
  • \$\begingroup\$ I just added a Debug.Log line under the GetButtonDown function and it seems like it doesn't get the key at all because the line did not print in the console. \$\endgroup\$ Sep 9, 2020 at 11:50

1 Answer 1

1
\$\begingroup\$

The reason why Pause is not working is, that as input for Pause in the input manager you set Joystick Axis as Type but you want "Key or Mouse Button".

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .