How do i make my game to focus on the IN game menu instead of the gameplay

How do i make my game to focus on the IN game menu instead of the gameplay. When i press escape and my IN game menu opens i want the “game” to focus on the menu and not on my fps player in the background. I mean when i have opened the IN game menu and press change weapon class etc my player fires a shot in the background at the same time… How do i fix this?

Unfortunately there isn’t a pretty solution right now; you have to create a flag.

In your character controller, check if the main menu is open. If it is, don’t take input from Input.GetKeyDown() etc. If you’re using a asset store FPS script, they might have a flag coded in there you can set.

Currently the most elegant way to solve this is to code a facade that replaces the Input class (e.g. Unity’s CrossPlatformInput class). Then you can set a universal flag to enable/disable player input. But sometimes that’s overkill depending on your situation. Maybe once Unity creates the new input system we can finally put this issue to rest.

Thanks for your help! Can you write here kind of what the code would look like in my character controller to check if the menu is open.

I guess i can write this in the update function in character controller? Will this code make the gameplay to “stop” while the menu is open?

OKey thank you!