Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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
0
Question by EpicGamer928 · Apr 13, 2013 at 08:42 AM · timescalepower upslow down

Power Up Script Problem!

I am making a simple jumping game and I have made a sphere which is going to be my power up. I want it so when I collide with the sphere, it sets the Time.timeScale to 0.5 for only 10 seconds. Then after the 10 seconds are up, it sets the Time.timeScale back to 1.

This is my current script:

 function OnTriggerEnter ()
 {
  Destroy(gameObject);
 Time.timeScale = 0.5;
 }

Right now when I collide with it, it destroys the power up and set the Time.timeScale to 0.5, but I can't figure out how to do this for only 10 seconds?

Any help or scripts 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
1

Answer by whydoidoit · Apr 13, 2013 at 08:43 AM

 function OnTriggerEnter ()
 {

    Time.timeScale = 0.5;
     yield WaitForSeconds(10 * Time.timeScale);
     Time.timeScale = 1;
     Destroy(gameObject);
 }
Comment
Add comment · Show 6 · 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 EpicGamer928 · Apr 13, 2013 at 01:53 PM 0
Share

Thanks so much! Will try the script out!

avatar image EpicGamer928 · Apr 14, 2013 at 01:22 PM 0
Share

Tried out script but does exactly what my old script used to do. It doesn't turn the time scale back to 1 after 10 seconds.

HELP!

avatar image whydoidoit · May 11, 2013 at 07:46 AM 0
Share

Updated the answer, shouldn't have been destroying the object (because it stops the coroutine) until after the time out.

avatar image whydoidoit · May 11, 2013 at 07:47 AM 0
Share

If you need it to be invisible for the time consider just moving it a long way at the start...

avatar image EpicGamer928 · May 12, 2013 at 10:42 AM 0
Share

Thanks, I'll try it!

Show more comments

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

11 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

Related Questions

OnTriggerEnter and transform.localScale with Time.deltaTime problem 2 Answers

Timecale=0 stops joystick. can it not? 1 Answer

Problem with finding the right syntax for time. 1 Answer

Pause menu... Isn't pausing everything... 1 Answer

How do I scale up a texture along with an ever-expanding underlying body ? 0 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