Make sure to put isPaused = false; at the end of the GoToMainMenu function, so that you can enable inputs if you decide to click play in the main menu!
I copied the code to the T and I keep getting errors like 'Time' does not contain a definition for 'timescale'. 'PauseMenu.isPaused' cannot be used like a method. And Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement. WHAT DO I DO?
Tip: If your pause menu spams like a minigun when you press Escape, you can change the if (Input.GetKey(KeyCode.Escape)) to if (Input.GetKeyDown(KeyCode.Escape)).
Even though you had project of yours that has already been nearly completed, you've successfully shown my dumb ass how to solve this particular "problem". Thank you so much
thank you so much for sharing your videos with us, I feel like I honestly learn more from you than the coding courses I've been taking !! You're very good at what you do :)
"gameManager" usually refers to an empty object where you asign all your codes in the scene (not related to the character or that kind of specific features). It function is to be the object that you will always call to make a code function work, in this case, to change your scene depending on the button you´re pressing. Its depends on you to give it to a principal camera or to an empty object tho
i followed brackeys tutorial on the same topic and it wouldnt work for me! i tried this one and it worked perfectly! thank you so much! im new to programming and video game development and your video just helped me out alot... you just gained a sub
I just have a little probleme, when i click on "resume" the first time, the next time i open the pause menu, if i press space the pause menu closed, even if my "space" button don't serve any purpose, not a big deal, but i'm curious to know why
Hey, so idk if youll see this but , My problem is that when the game is up the text choices "resume , quit " etc are overlayed on the game and it wont disappeared . they do work when I hit esc and the paused title comes up but the choices never leave?
Hi, I'm just wondering I don't have a game manager and I don't know where to put the script so it's not working could you please tell me how where to actually put the script if I don't have a game manager?
Perfect, thanks! I'm just starting with all this and being able to set the timescale was the piece of the puzzle I was missing. Until now I had been setting a bool for "canMove" to false and wrapping it around every single movement command on my character but I was wondering what I would do about enemies and other environmental objects. I knew I could always give them something similar, but then having to tie all that in to a player pressing a key seemed awfully excessive. This looks like a much better solution!
Now that I think about it, I guess this is also where you could add a feature like Rimworld has where you have multiple play speed buttons or special effects like time slowing when you get hit with a fatal blow. Really good to know!
for those who have issue with UnassignedReferenceException error, go chack out "PAUSE MENU in Unity" by Brackeys, he did it in a slightly different way and it works
Hello there, I don't know why but my button to return to the menu works again but when I start the game again the assignment in On Click ( ) is lost, I don't understand, it worked once, and the second time I try to play it doesn't work Start?
Hey, great tutorial! I was wondering if there's a way to stop the Standard Assets FPS Controller from letting the player still move the camera around when the pause menu is up, haven't been able to figure it out myself. Thank you!
Thank you! But I have a question. The game that I'm making is for Android and for making the game in pause I have to click a button with a clicking function. I putted that but when I press the button the player jumps because of the function that is *if(Input.GetMouseButtonDown(0) && canJump)*. That is a disturbing thing because when I want to pause the game the player jumps. If you could help me I would be rrally grateful!
Doesn't work for me im getting and issue with assigning it to a game object The game is freezing when I hit esc but there is no menu popup Im trying to figure it out right now but there's an issue with setting the script to something, and then putting something as a the gameobject for pausemenu Edit - I believe it has something to do with the camera settings Edit 2 - Yes it was the canvas, once I set it to follow the camera it made my already small menu microscopic. So I saved a copy of the panel, made the change, then repasted the panel and it's perfect. Now my pause menu follows my camera screen which is what I wanted. You need to set the pausemenu as a gameobject in the pause menu script Edit 3 - You cannot call PauseMenu from another CS script it does not exist You have to import it
Assets/scripts/PauseMenu.cs(50,43): error CS1002: ; expected if you get this error it’s a typo and you got carried away typing all that code and forgot to put a single ; at the end of your line.
@@whysl oh was this comment still here I forgot to delete I solved this problem 7 days ago but I’m still gonna leave it here just if anyone is an idiot like me and makes any typos.
Hi- I’m using SC_FPSController script and I can’t freeze the the camera moving with the mouse (so can’t stop player movement) Should I unconnected them so solve that??
UnassignedReferenceException: The variable pauseMenu of PauseMenu has not been assigned. You probably need to assign the pauseMenu variable of the PauseMenu script in the inspector. PauseMenu.PausedGame () (at Assets/Scripts/PauseMenu.cs:35) PauseMenu.Update () (at Assets/Scripts/PauseMenu.cs:23)
how could i make a pause menu for a multiplayer fps game? because when I press escape, the cursor still moves my camera for whatever reason, even if I have an if else condition in place to prevent that
Someone help me please! is giving the error: "The name (Principal) is not in the context csharpCS0103". This code would be to change the scene, in this case it would be for the Main Menu scene, I changed the scene name to "Principal" but it will not go at all!
This is very late but the way to fix this (i think) is to 1.) Go to the top left 2.) Click on file 3.) Click on build settings 4.) Drag and drop all your scenes into the big space (make sure you drag them into the order you want people to see it in)
I've found the solution though! Go to Edit -> Project Settings->Player->Under Other Settings under Configuration is the option Active Input Handling. Select Both. Hope this helped!
A "touch" registers as a mouse click. It can easily work with Mobile. Instead of pressing the Escape key you'd need some sort of Pause button on the screen
why my functions (pauseGame(), resumeGame()) are not appearing in inspector when on click() .. i have put the the script in separate gameobject and applied this game object in on click() .. still not functions of the script appearing, why?
ok but now how do i make it work... like i do make pressing the quit game button quit the game and make the resume game resume it when you click it or the back to menu take me to the main menu
Create a GameObject, rename it GameManager. Create a script called "GameManager" or whatever you'd like and attach it to the GameManager... Theres nothing requiring you to name your object/script "GameManager" its just called that by convention for other programmers to understand its purpose, which has value, but just understand its not required.
Hi, thanks for the video! To stop receiving inputs for the gamepad(it's moving the character even when paused) e still making it available to navigate the menu, how do I achieve that?
I know this video is super old and no one cares, but is the audio from the beginning from Juice Universe? (I believe that's what it's called now after it got renamed)
I HAVE A PROBLEM Escape button do not work and i checked in the setting in the Input Manager to affect the name in the code as the name of the button in the settings... PLEASE HELP
unity has a defult setting that makes the escape key allow you to move your mouse outisde the game viewer to exit play mode, i set it to Q for me for testing purposes
I would change it to “…GetKeyDown(KeyCode.P)) “ For it to work as when playing a game you don’t really want to press “esc” as takes away from immersion
UnassignedReferenceException: The variable pauseMenu of PauseMenu has not been assigned. You probably need to assign the pauseMenu variable of the PauseMenu script in the inspector. PauseMenu.Start () (at Assets/Scripts/PauseMenu.cs:14) PauseMenu.ResumeGame() (at Assets/Scripts/PauseMenu.cs:42) what I miss or did wrong?
so where exactly am i supposed to put the PauseMenu script? like ive written the code and stuff but i dont know what im supposed to add the script to so it actually works, someone help please?
my main menu is stuck for some reason after going from the pause menu, what could be the problem ? i hope someone answers asap really need it for school
Make sure to put isPaused = false; at the end of the GoToMainMenu function, so that you can enable inputs if you decide to click play in the main menu!
Thank you for this comment!
THANk YOU
I copied the code to the T and I keep getting errors like 'Time' does not contain a definition for 'timescale'. 'PauseMenu.isPaused' cannot be used like a method. And Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement. WHAT DO I DO?
@@austinschaefer804 idk
@@austinschaefer804 Are you still having trouble? If so, show me your script, I may be able to spot the issue, but I need the script.
Thanks for making it simple and to the point. I appreciate the lack of useless filler that most people go for
Thanks for the kind feedback!
having a youtuber that makes content on exactly what i need and in 2020 is godly. thanks!
your videos are super well made, beginner friendly, and perfect for game jams! please continue making tutorials!
That makes me really happy you think that, no plans to stop yet!
@@BMoDev I 100% agree with this guy, every question i've had in the past 24 hours your channel has answered in the most accessible way. Thank you!
Tip: If your pause menu spams like a minigun when you press Escape, you can change the if (Input.GetKey(KeyCode.Escape)) to if (Input.GetKeyDown(KeyCode.Escape)).
hahahah epic comment!
+i want to thank you for this gem! I have been trying for hours to fix it!
bro finna be honest THIS GUY SOUNDS AWESOME his voice is so calming and soothing. Never got a more awesome experience from coding thanks man.
Thats crazy to me, but I appreciate it 💙
Even though you had project of yours that has already been nearly completed, you've successfully shown my dumb ass how to solve this particular "problem". Thank you so much
thank you so much for sharing your videos with us, I feel like I honestly learn more from you than the coding courses I've been taking !! You're very good at what you do :)
5:48 what is my gameManager ? the Camara ?
"gameManager" usually refers to an empty object where you asign all your codes in the scene (not related to the character or that kind of specific features). It function is to be the object that you will always call to make a code function work, in this case, to change your scene depending on the button you´re pressing.
Its depends on you to give it to a principal camera or to an empty object tho
i followed brackeys tutorial on the same topic and it wouldnt work for me! i tried this one and it worked perfectly! thank you so much! im new to programming and video game development and your video just helped me out alot... you just gained a sub
Happy to hear it! Keep it up!
BMo thanks!
@@BMoDev for some reason the player is blocking the pause menu buttons from working
these tutorials are so useful for my game development, keep up the great content
This really makes me happy to hear! Will do my best 🙏 I want more people bringing their ideas to life!
I wish all tutorials were like this you know very short direct to the point and entertaining.
again, i search "Unity 2d pause menu" and the second video is this one, like the other, i'm not disappointed, i think i'm going to subscribe x)
I just have a little probleme, when i click on "resume" the first time, the next time i open the pause menu, if i press space the pause menu closed, even if my "space" button don't serve any purpose, not a big deal, but i'm curious to know why
Hey, so idk if youll see this but , My problem is that when the game is up the text choices "resume , quit " etc are overlayed on the game and it wont disappeared . they do work when I hit esc and the paused title comes up but the choices never leave?
Tip: you actually cant put script everywhere u want (not on PauseMenu because script wont work if u disable gameobject :D)
Good advice, i had that problem n now i know how to solve it. Thanks
Hi, I'm just wondering I don't have a game manager and I don't know where to put the script so it's not working could you please tell me how where to actually put the script if I don't have a game manager?
This is perfect. Thank you for the efficient rundown!
Thanks for the tutorial ! It's very nice and I really needed that !!
Looking forward your next 5min videos !!
Perfect, thanks! I'm just starting with all this and being able to set the timescale was the piece of the puzzle I was missing. Until now I had been setting a bool for "canMove" to false and wrapping it around every single movement command on my character but I was wondering what I would do about enemies and other environmental objects. I knew I could always give them something similar, but then having to tie all that in to a player pressing a key seemed awfully excessive. This looks like a much better solution!
Now that I think about it, I guess this is also where you could add a feature like Rimworld has where you have multiple play speed buttons or special effects like time slowing when you get hit with a fatal blow. Really good to know!
And you can qui...
Im learning with your tutorials thanks a lot :)
Awesome, keep it up!
Dude you are my new god, thank you so much :D
im using both youtube tutorials and chatgpt both help a lot. first i get what i want on youtube than expand with chatgpt, and im actually learning.
Make sure that you change isPaused bool to false in the Main menu function, otherwise your controls will be locked when you play again
thanks i'll trying all day to find out
You're a beautiful human being Mr.BMo.
When I press escape pause menu doesn't show up any solution?🥺
Is "pauseMenu" the name of an existing object or is it assigned to the menu by the script?
for those who have issue with UnassignedReferenceException error, go chack out "PAUSE MENU in Unity" by Brackeys, he did it in a slightly different way and it works
Why the hell are you so underrated? These are some straight on point Tutorials man! Thanks
This helped me so much thank you kind stranger
ThankYou so much dude your vids been helping out a lot recenly
Hello there,
I don't know why but my button to return to the menu works again but when I start the game again the assignment in On Click ( ) is lost, I don't understand, it worked once, and the second time I try to play it doesn't work Start?
when i try to click a button my cursor disables and goes into the game
Your game locks your mouse so you have to make it unlock when it's paused and relock when resumed
@@a26lolhart thanks for replying 8 months later
You're the Goat. Helped me out a ton.
I came across this video and it helped fix a bug in my pause menu so THANK YOU =>
Can you make a gameover menu thing couse i'm stuck with things like that
Sure, I'll add it to my backlog
Hey, great tutorial! I was wondering if there's a way to stop the Standard Assets FPS Controller from letting the player still move the camera around when the pause menu is up, haven't been able to figure it out myself. Thank you!
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
player.SetActive(false);
I've used your code to make a death screen, but when i die my mouse doesn't show up, do you know why this is?
Thank you! But I have a question. The game that I'm making is for Android and for making the game in pause I have to click a button with a clicking function. I putted that but when I press the button the player jumps because of the function that is *if(Input.GetMouseButtonDown(0) && canJump)*.
That is a disturbing thing because when I want to pause the game the player jumps. If you could help me I would be rrally grateful!
When i go to "on click()" - button i dont have the options that u have
Thank you so much for this, you´re a life saver!
can you put the script in comments/description?
if i was making a 3D game how would i stop my camera from moving around when im in the menu
thank you for this great video, plain and simple!
Awesome tutorial. I have a pause menu now.
Nice work!
Doesn't work for me im getting and issue with assigning it to a game object
The game is freezing when I hit esc but there is no menu popup
Im trying to figure it out right now but there's an issue with setting the script to something, and then putting something as a the gameobject for pausemenu
Edit - I believe it has something to do with the camera settings
Edit 2 - Yes it was the canvas, once I set it to follow the camera it made my already small menu microscopic.
So I saved a copy of the panel, made the change, then repasted the panel and it's perfect. Now my pause menu follows my camera screen which is what I wanted.
You need to set the pausemenu as a gameobject in the pause menu script
Edit 3 - You cannot call PauseMenu from another CS script it does not exist
You have to import it
Amazing tutorial. Many thanks!!
Assets/scripts/PauseMenu.cs(50,43): error CS1002: ; expected
if you get this error it’s a typo and you got carried away typing all that code and forgot to put a single ; at the end of your line.
just put the ";" symbol in 50 line
@@whysl oh was this comment still here I forgot to delete I solved this problem 7 days ago but I’m still gonna leave it here just if anyone is an idiot like me and makes any typos.
im using the same version as you and before you did the static ball and yeah in my 3d it doesnt work
Thank you!! Your videos are awesome
While this method is great for tiny games, hard setting the timescale will often lead to issues in larger games.
Hi- I’m using SC_FPSController script and I can’t freeze the the camera moving with the mouse (so can’t stop player movement)
Should I unconnected them so solve that??
bro how to off al sounds when the game is pused
UnassignedReferenceException: The variable pauseMenu of PauseMenu has not been assigned.
You probably need to assign the pauseMenu variable of the PauseMenu script in the inspector.
PauseMenu.PausedGame () (at Assets/Scripts/PauseMenu.cs:35)
PauseMenu.Update () (at Assets/Scripts/PauseMenu.cs:23)
just assign the variable
How i can do this?
@@tobystorahhow?
Oh my god, it's been 3 fucking years, I was so dumb bro 😂
@@TBag-xl9qz google "how to assign a variable in C#" or in these days ask chatgpt
very quick and to the point, I appreciate that :]
how could i make a pause menu for a multiplayer fps game? because when I press escape, the cursor still moves my camera for whatever reason, even if I have an if else condition in place to prevent that
Smashed the like as hard as I could have
My man 🙏
*smash that like button two times!*
Someone help me please! is giving the error: "The name (Principal) is not in the context csharpCS0103".
This code would be to change the scene, in this case it would be for the Main Menu scene, I changed the scene name to "Principal" but it will not go at all!
That could be referring to the UI element.
That happend to Me too
Coz ist fake
This is very late but the way to fix this (i think) is to
1.) Go to the top left
2.) Click on file
3.) Click on build settings
4.) Drag and drop all your scenes into the big space (make sure you drag them into the order you want people to see it in)
Great tutorial, but this doesn't work with unity's new input system.
I'm dealing with the same issue right now.
I've found the solution though!
Go to Edit -> Project Settings->Player->Under Other Settings under Configuration is the option Active Input Handling. Select Both.
Hope this helped!
@@baron_shiro9877 It does, thanks, but I think I might stick with the old input system as there are more supported assets/scripts for it
@@baron_shiro9877 Thank you!
oh my god it works thanks!!
is this working with touches ??
i want to make it for my android mobile game?
A "touch" registers as a mouse click. It can easily work with Mobile. Instead of pressing the Escape key you'd need some sort of Pause button on the screen
@@BMoDev a pause button connected with the menu , thanks
'PauseMenu' does not contain a definition for 'isPaused'-error is popping up. how do i fix this?
Hi my script isnt working and would like help my script is making the buttons work
Hey can someone help, the button doesn't change colors like it does in 3:09
You have to change the colour in the settings of the button to have the colour change when you hover/click on the button
I don't have anything like GameManager... What gameObject should I put into "On click" event instead?
canvas
you put the scirpt in the canvas
why my functions (pauseGame(), resumeGame()) are not appearing in inspector when on click() .. i have put the the script in separate gameobject and applied this game object in on click() .. still not functions of the script appearing, why?
This is perfect but when I pause the game, I can still move my character even when paused and in pause menu. How to prevent this?
look into pausing time in unity
So I have a fade into scene ui in my project, and so now my buttons don’t press because of it. Anyway to fix this? Thanks
Ty so much, you helped me a lot!!
For some reason my buttons aren't working at all, can't click or hover on them. Any possible causes?
You might not have an EventSystem?
Thanks a lot, much appreciated
ok but now how do i make it work... like i do make pressing the quit game button quit the game and make the resume game resume it when you click it or the back to menu take me to the main menu
If l make a pause menu in a mobile game made by unity then how I will pause game in mobile??
There could be a button in the corner of the screen you tap to trigger PauseGame, and then a Resume button on the menu.
Ok Thx
how do i create a game manager
Create a GameObject, rename it GameManager. Create a script called "GameManager" or whatever you'd like and attach it to the GameManager... Theres nothing requiring you to name your object/script "GameManager" its just called that by convention for other programmers to understand its purpose, which has value, but just understand its not required.
there's an error with GameObject
i got the menu button and quit button to work but i cant resume the game or push escape to take the menu away
I dont know where you put the script, becasue you said it doesnt matter where the script lives but it clearly does as its not working for me
What kind of error you getting? Whys it not working?
Time.timeScale, affects button animations, how to avoid it?
what is the gamemanager object type?
its the canvas
How do you fix it so it works after you have buildt and run the game? Only works in game tab in the editor but not in the buildt version
does anybody know how to make it not lock back to the camera if im making a fps game?
finished the PauseMenu script. error The Name 'PauseGame' does not exist in the current context. pls help?!
Check to see if your PauseGame() function has a typo
Hi, thanks for the video!
To stop receiving inputs for the gamepad(it's moving the character even when paused) e still making it available to navigate the menu, how do I achieve that?
Helped so much! 👍
Very helpful! thanks
Hmm I'm pressing the button but the menu does not come up. I already added the gameobject to the script as well. Can anyone help?
I'm using this for a VR game, however with this script i cannot interact with the buttons, without the script i can. Any ideas how to fix that?
What vs code extensions do u use for unity
I know this video is super old and no one cares, but is the audio from the beginning from Juice Universe? (I believe that's what it's called now after it got renamed)
thx but i dont have the same GameManager as u ////Help
Thanks! Good video!
I HAVE A PROBLEM
Escape button do not work and i checked in the setting in the Input Manager to affect the name in the code as the name of the button in the settings...
PLEASE HELP
unity has a defult setting that makes the escape key allow you to move your mouse outisde the game viewer to exit play mode, i set it to Q for me for testing purposes
I would change it to “…GetKeyDown(KeyCode.P)) “
For it to work as when playing a game you don’t really want to press “esc” as takes away from immersion
UnassignedReferenceException: The variable pauseMenu of PauseMenu has not been assigned.
You probably need to assign the pauseMenu variable of the PauseMenu script in the inspector.
PauseMenu.Start () (at Assets/Scripts/PauseMenu.cs:14)
PauseMenu.ResumeGame() (at Assets/Scripts/PauseMenu.cs:42)
what I miss or did wrong?
I have the same problem and I can't figure it out
Same here
Same
Does anybody know why the scene afterwards is pitch black after i did the main menu
Why is my game already paused when i start it?
Helppp !!! How do i press the resume button, the game goes back. Thanks
do you mean when you click resume nothing happens?
@@Cjoudan Yeah
How can I make the escape button android friendly?
What if you have animations and want to use them? Example you have options button and want to make it slide in the option screen if you click on it.
sail to Ukraine🙂
so where exactly am i supposed to put the PauseMenu script? like ive written the code and stuff but i dont know what im supposed to add the script to so it actually works, someone help please?
same problem, did you find a solution?
@@SaraCusimano no sorry lol i never figured it out, i hope you do tho, good luck!!
put the PauseMenu script in the game manager.
my main menu is stuck for some reason after going from the pause menu, what could be the problem ?
i hope someone answers asap really need it for school
Time.timeScale doesn't seem to work on my Unity.
Edit: For that matter, neither does triggering the paused bool.
try looking through the package manager sry if im to late