How do I stop Camera Controls with pause menu

Hello, I finished this project recently and I was trying to add a pause menu so I could pause the game. I got the canvas implemented and got it to appear when I open the menu but I can still control the camera while paused. I attached some screenshots of my code. I was wondering if there was a way to stop camera controls while a bool is true.

So it looks like you’re updating Movement, Rotation and Zoom when the game IS paused, rather than when it isn’t paused.

Try

if(!PauseMenu.Instance.IsgamePaused)

@Brian_Trotter Thanks for the reply!
I tried what you recommended but I get this error. The error occurs on play, not even pressing any buttons.


Here are some other images of my scripts. Not sure why I’m getting a Null Reference Exception though.

I figured out the Issue, I forgot the add the
if(Instance != null) { Debug.LogError("More than one UnitActionSystem" + transform + " - " + Instance); Destroy(gameObject); return; } Instance = this;

After adding this to the PauseMenu everything worked fine. Thanks for the help!

Glad you got that working! That’s correct, if the instance isn’t set, then you’ll get null references.
For future code pastes, paste in the text of the script rather than using a screenshot.

1 Like

Thanks for the Tip about code formatting!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms