Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Apr 17, 2014 at 02:06 AM by thornekey for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by thornekey · Apr 09, 2014 at 09:03 AM · c#errorpause

Pause menu not working..

Hi, i have made a pause menu which slightly works... I want to disable the mouseLook and movement scripts on the player when they do pause.. this script is on an object called GameMaster so i am trying to access the player (where these components are..) but when i pause i can still move the camera around, etc..

             if (pause == true && networkView.isMine) {
             GameObject.FindWithTag("Player").GetComponent<CharacterController>().enabled = false;
             GameObject.FindWithTag("Player").GetComponent<MouseLook>().enabled = false;
             GameObject.FindWithTag("Player").GetComponent<CharacterMotor>().enabled = false;
             }
             else if (pause == false && networkView.isMine){
             GameObject.FindWithTag("Player").GetComponent<CharacterController>().enabled = true;
             GameObject.FindWithTag("Player").GetComponent<MouseLook>().enabled = true;
             GameObject.FindWithTag("Player").GetComponent<CharacterMotor>().enabled = true;
             }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image thornekey · Apr 09, 2014 at 09:42 AM 0
Share

is there a better way to do this??

1 Reply

  • Sort: 
avatar image
-1

Answer by sedativechunk · Apr 09, 2014 at 10:06 AM

Yes, there is a better way to do this. I've always had a good mind for how to do pause menus easily. One of the simpler ways as far as Unity goes is to create an empty game object called "activestate" for example. In this activestate game object, you can put EVERYTHING that runs your actual game, ex. the player, level, background, environment, etc.

When the player pauses the game, you can disable the entire state of this "activestate" game object and display another game object instead with your pause menu. If you use this method, then instead of tinkering with tons of different things and tags you only have to disable one single game object. When you reactivate it, everything in there should be as is when the state was last active (except objects that use the "awake" functions may need tweaked a bit).

Another kind of trick (although not anywhere nearly as effective) is to manipulate the time. If you programmed your game correctly, most of the actions/movements/physics are multiplied by "Time.DeltaTime" or "Time.Time". You could maybe modify those values to multiple by 0 when in pause state. Then the game will "freeze" in action. Just another interesting way to go about it. I prefer the previous method I mentioned.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image thornekey · Apr 09, 2014 at 10:27 AM 0
Share

note, that this game is multiplayer, so I thought that just disabling the scripts would be best suit for it.

avatar image sedativechunk · Apr 09, 2014 at 06:01 PM 0
Share

I think you could still use this method if you are doing multiplayer, you need to have a script outside of the disabled game objects to handle it. That might even be your problem now, if you are disabling anything that is handling the networking then it's going to cause a problem.

avatar image thornekey · Apr 10, 2014 at 04:18 AM 0
Share

@pako - only for the player that pauses. I just want it so they can free their mouse and change settings, etc without their camera moving.

@sedativechunk - technically this is the outside script. Im trying to access the players scripts and disable them. This is the Game$$anonymous$$aster script. the pause menu is just a small box with a few buttons. If the other player walks by, I want them to still see them walk by.. Just not be able to move. So again, slowing speed down still wont work for it.

saying this:

  if (pause == true && networkView.is$$anonymous$$ine) {
          GameObject.FindWithTag("Player").GetComponent<CharacterController>().enabled = false;
 }

looks logical, and should technically work; but I think im just missing something slightly thats causing the whole thing not to work.

this is the error im getting:

 NullReferenceException
 UnityEngine.GameObject.GetComponent[CharacterController] ()
 Game$$anonymous$$aster.Update () (at Assets/Game$$anonymous$$aster.cs:116)
avatar image thornekey · Apr 14, 2014 at 11:36 PM 0
Share

Still no working solution, sadly. The above error is still occurring.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I am having a parsing error in a C# pause script, can anyone help? 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Unexpected Strange Behavior 0 Answers

Code Problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges