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 /
avatar image
0
Question by SaplingGames5 · Jan 12, 2021 at 04:52 AM · pausing

How would I stop my camera at a specific time

So I'm trying to make my camera stop moving whenever I pause my game. Now I got the camera to work while the game is un paused, but I don't understand how to stop it from moving while the timescale = 0. Extra context/short description: I'm doing an fps controller but when I pause the camera keeps moving as my mouse does.

Here is my code:

 public Transform player;
 public static bool GameIsPaused;

 void Update() {

     if (GameIsPaused != true)
         StartLook();

     if (GameIsPaused = true)
         StopLook();
 }

 void StartLook()
 {
     transform.position = player.transform.position;
 }

 void StopLook()
 {
     ///this is where I'm having a hard time at use the code from StartLook() to help you
 }
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
0

Answer by jackmw94 · Jan 12, 2021 at 10:35 AM

The only obvious issue I can see with this code is that your check for whether the game IS paused isn't using the double equals "equality operator", the single equals is the "assignment operator".

When you do GameIsPaused = true we will always return true regardless of what value GameIsPaused starts as. This is because the first thing this line does will be to ASSIGN GameIsPaused to equal True. Since it's the condition for an if-statement it will then look at the result of this operation which is now also True.

To solve this, use the equality operator GameIsPaused == true to check whether the GameIsPaused is equal to True. Since this will return a True or False value, this is equivalent to just writing if (GameIsPaused)

Unless it's acted upon by other forces, to NOT move something you simply need to neglect to move it. So I would have thought an empty StopLook function is fine, as long as we don't enter StartLook then there is no reason - from this code - that it should move.

From your description, I've got a feeling there is more code affecting the camera behaviour. If making this change doesn't help then reply with any other code that is handling the 'look' rotation of your camera :)

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

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

111 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 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 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 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 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

Pausing issue with OnMouseDown 1 Answer

How do I pause and unpause multi gameobjects in the scene for a five seconds 1 Answer

Website responsiveness and Unity hogging the CPU 1 Answer

Time.realTimeSinceStartup behaves weirdly when sending app to background or locking the screen. 1 Answer

Simple Android project shuts down when user presses the Recent Apps button 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