Clicking Resume button on my pause window fires a bullet on return to game.

Working on a space shooter game. just added a pause window and if I click the mouse while paused and then hit escape to unpause the game or if I click the resume button the game will unpause but a single bullet is fired.

I have tried getting button Fire1 when unpausing and also Input.ResetInputAxes() but it still fires the single bullet. Any ideas of what I am doing wrong?

public void TogglePauseGame()
{
if (Time.timeScale > 0)
{
Time.timeScale = 0;
gameObject.active = true;
}
else
{
Input.ResetInputAxes();
gameObject.active = false;
Time.timeScale = 1;
}
}

Thanks,
-E

Looks like my cannon Update() is still being called. I have added a check for Time.timeScale > 0. This has fixed my issue but I would like to know if there is a more elegant way or a better pattern to adhere to. Thanks in advance for any help.

-E

You could disable the cannon script on pause, then re-enable the script on unpause. This way the Update isn’t called while paused.