Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by jeffreyyourman · Aug 28, 2015 at 11:12 AM · loadleveltimer countdown

(Help Please) How to load new level one count down time hits zero?

Hello, i am trying to do create a game, but I am trying to have a countdown timer that once it hits zero it will load the game over scene. I currently have the count down timer working perfectly, but I am a little bit confused on where to put the once the timer ends it will load the game over scene.

here is my script for the timer section

http://pastebin.com/iTKDtsXv

and then here is my code that is attached to the timer for my player controller

http://pastebin.com/hnKbnPAn

please help me in any way possible! I am so close to finishing my game but I have completely hit a near dead end. Thanks for any help in advance

Comment
Add comment · Show 3
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 Ekta-Mehta-D · Aug 28, 2015 at 10:39 AM 0
Share

If you want to load new gameover scene when timer ends for thet you have UpdateTimer() in TimerController.

                 if (remainingTime > 0.0f)
                 {
                         SetTimerString(remainingTime);
                 }
                 else
                 {
                         // Load gameover scene
                  }

avatar image jeffreyyourman · Aug 29, 2015 at 05:32 PM 0
Share

Hey so that worked perfectly! I just have kne more question. I have the countdown timer set up and everything. But I also have a respawn script attached to my player and a platform so if the player falls off platform it respawns in the same spot as if the game just started with the countdown timer continuing. So my issue is I can't figure out when the player falls off I want to subtract lets say 5 seconds from the countdown timer. So lets say the player falls off platform at 60 seconds remaining i want it to subtract 5 seconds and then respawn the player. I have two scripts that I am using. Here is the TimerController script

http://pastebin.com/bdHJ2i55

And here is the respawn script.

http://pastebin.com/ZJQ$$anonymous$$pFAq

Please email me at jeffreyyourman@gmail.com

avatar image hulahoolgames · Aug 29, 2015 at 05:49 PM 0
Share

You can put a collider underneath your platform and when the player hits the collider you know he has fallen off the platform and respawn him. Or you can just check the vertical position of you player with respect to the platform and know if he is below it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ransomink · Aug 29, 2015 at 07:37 PM

You will need to declare var remainingTime outside of Update() in order to access it from another script.

You can keep it private and create a getter/setter, then set its new value after the player falls; Or, use a function created inside the TimeController class and call it:

 public void function SubtractFromTimer(float time)
 {
     remainingTime -= time;
 }

As @OG23 mentioned, you can place a collider/trigger underneath the platform and when the player enters said collider, respawn the player and subtract from the remaining time.

Hope this helps!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

I'm confused, Application.loadedLevelName not working 1 Answer

Duplicate scene will make Awake function problem? 0 Answers

Game works fine inside editor but takes forever to load after build. 0 Answers

DateTime Timer not working when loading the correct timer amount?? 1 Answer

Trying to create a timer that runs outside the Game 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