Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
avatar image
1
Question by Waffle842 · Oct 18, 2013 at 06:55 PM · c#cameramovementpause

[Solved it] Disable Camera Movement on Pause (C#)

Alright quick question. I tried looking around first and I am either dumb and don't know how to implement something, or something else is wrong. So I attempted to give my game the ability to pause, and for the most part I was successful. My only problem now is the camera still moves when the game is paused. I know that I am supposed to find the first person camera script and disable it but everything I try throws up errors. Here is my script so far without any of my attempts to fix the camera.

 // Use this for initialization
 void Start () 
 {
 
 }
 

 void Update () 
 {
     
     if (!isPaused)
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             pause();
         }
     }
     else 
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             pause ();    
         }
     }
     
 }
 void pause ()
 {
     if (!isPaused)
     {
         isPaused = true;
         Time.timeScale = 0;
         
         
     }
     else 
     {
         isPaused = false;
         Time.timeScale = 1;

     }
 }

 void OnGUI()
 {
     if (isPaused)
     {
         GUI.skin = boxSkin;
     
         
             GUI.Label(new Rect(500,175,200,55), "Paused");
             
     }
 }

}

nevermind, i figured it out, i just added a second script for the camera, because it turns out the controller mouselook controls up and now and the camera mouselook controls left and right. I then added 'GetComponent().enabled = false;' to both scripts and 'GetComponent().enabled = true;' on the else. I also removed the gui component on the camera so I didn't get Two pause words.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Waffle842 · Oct 18, 2013 at 07:06 PM

nevermind, i figured it out, i just added a second script for the camera, because it turns out the controller mouselook controls up and now and the camera mouselook controls left and right. I then added GetComponent().enabled = false; to both scripts and GetComponent().enabled = true; on the else. I also removed the gui component on the camera so I didn't get Two pause words.

like so { if (!isPaused) { isPaused = true; Time.timeScale = 0; GetComponent<MouseLook>().enabled = false; } else { isPaused = false; Time.timeScale = 1; GetComponent<MouseLook>().enabled = true; } }

Comment
Add comment · Show 1 · 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 CraftyMaelyss · Oct 19, 2016 at 06:17 AM 0
Share

Could you put up an example script that has the new code included because I tried it and I get errors :(

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 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

Related Questions

Making a bubble level (not a game but work tool) 1 Answer

Head Bobbing Effect is Glitching Out on Collision 0 Answers

Keeping an object constrained to a 2d radius based off of the camera 0 Answers

Disable Camera Movement,Stop camera movement 0 Answers

Regarding transform.position in the roll a ball tutorial 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