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 ArcIo · May 12, 2012 at 02:39 AM · rotationplatformerpause

Why does my rotating platform not pause when I pause the game?

I have been learning JS and really getting into it. I mocked up a level and began building it. I added a rotating cylinder that has a series of platforms that rotate counter to that of the cylinder.

Looks like a ferris wheel. The cylinder moves one way while the platforms move the other. This gives a nice effect of seeming like they are hinged to the cylinder.

here is where the problem comes in. I added a pause menu. When I pause the game, everything stops as expected, sans the items rotating.

Not really sure why this is happening but here is some code if anyone wants to take a crack at it.

// code for Platform.js

 var rotatePlatformCW : boolean = false;
 var rotatePlatformCCW : boolean = false;
 var speed : int = 5;
 
 function Update(){
     if (rotatePlatformCW == true){
         transform.Rotate(0, -.35, 0 * Time.deltaTime);
         }
     else if (rotatePlatformCCW == true){
         transform.Rotate(0, .35, 0 * Time.deltaTime);
         }
     }

// Code for Pause.js

 var paused : boolean = false;
 var pauseIcon : Texture;
 var pausedTime : float = 0.000001;
 var unpausedTime : float = 1.0;
 
 function OnGUI () {
     if (GUI.Button (Rect (Screen.width - 100,Screen.height - 50,100,50), pauseIcon)) {
         if (paused == false){
             paused = true;
             Time.timeScale = pausedTime;
             }
             else if (paused == true){
                 paused = false;
                 Time.timeScale =unpausedTime; 
                 }
             }
         print ("The Game is Paused");
 }

Any help is greatly appreciated!

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
2
Best Answer

Answer by rutter · May 12, 2012 at 08:56 AM

I see two snags.

First, it looks like you're setting Time.timeScale to a very small number, but not zero. Maybe there's a reason for that, but it seems a little strange to me. Super slow motion? Not necessarily a problem, but I figured I'd point it out.

Second, you probably realize that your behavior scripts will still get Update() calls while time is "frozen" -- the only inherent difference is that time steps will be zero (or, in your case, incredibly small). With that in mind, let's take a look at your rotation code:

 transform.Rotate(0, -.35, 0 * Time.deltaTime);

You probably want to multiply that second parameter, rather than the third one? Multiplying by zero will always produce zero. Meanwhile, the second number is not being scaled by your frame time.

If you want, there is an overload for transform.Rotate() which takes a vector; if you use that call, you can scale all three axes with one multiply operation. If you're pretty sure you only want to rotate on the one axis, this is sort of a moot point, of course. :)

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 ArcIo · May 14, 2012 at 05:51 PM 1
Share

Bingo! or as my dad says Bingo Bango. So the time thing is correct, I want things to not truly freeze when pausing. however, I was able to get everything else in my scene to freeze but was multiplying my deltaTime by actual numbers.

Brilliant. However this does give me an interesting idea for gameplay mechanics.

Thanks rutter!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Character Controller falls through moving/rotating platforms (Not A Duplicate Post) 1 Answer

Getting the face direction 2 Answers

Setting rotation but with an offset. 0 Answers

How to keep local rotation when using raycasts? 1 Answer

Flip over an object (smooth transition) 3 Answers


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