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 Dakinegabe117 · Jun 01, 2015 at 05:53 PM · timercountdowncombine

How to make timer activated after 321 go, no at the same time?

I want my timer to activate after my countdown script has hit 1. Right now the timer activates at the same time as my 3 2 1 go script since they are two seperate Java Scripts, how do I combine them so that it goes 3 2 1 and then the timer kicks in?

FYI this is a racing game.

My CountDown script to start game 3 2 1 go!

var guiCountDown : GUIText; var countMax : int; private var countDown : int; function Start () { guiCountDown.enabled=true; GameStart();

}

function Update () {

}

function GameStart() { var car = gameObject.Find("F1Car"); var drivingScript = car.GetComponent("CarControlScript"); drivingScript.enabled=false;

 for (countDown = countMax; countDown>0;countDown--){
     guiCountDown.text = countDown.ToString();
     yield WaitForSeconds(1);
 }
 guiCountDown.enabled=false;
 drivingScript.enabled=true;

}

My Timer script

var timer : float = 60;

function Update () { timer -= Time.deltaTime; if(timer <- 0) { timer = 0; Application.LoadLevel("TooSlowScene"); //Does something after reaching 0 } } function OnGUI() { GUI.Box(new Rect(50, 50, 50, 20),"" + timer.ToString("0")); }

Comment
Add comment · Show 1
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 SterlingSoftworks · Jun 01, 2015 at 10:22 PM 0
Share

If I'm reading your code correctly.. Where you have time -= Time.deltaTime; put it in an if statement like this:

 if (guiCountDown.enabled == false){
     timer -= Time.deltaTime;
 }

This should only activate once the guiCountDown is deactivated, which is right as the count down stops.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by redeemer · Jun 01, 2015 at 11:29 PM

Hi Dakinegabe,

In my opinion you should use the new UI system if possible. I've done a really simple scene with what I think is you are trying to acomplish (the count down 3, 2, 1 is in red, Go! in green at the middle and the overall timer in black at the top). You can modify it to use GUI.Box, but I think you'll have better results and control over your UI if you change to the new UI system.

CountDown Example Scene : https://mega.co.nz/#!r8VliYzS!m3ePDHSsCzYyLpDd-pyH7Z82BeedxKg_JetYqEiCjvs

If you need any help or clarification about the scene set up or the scripts, please ask.

Hope this helps.

Comment
Add comment · Show 2 · 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 Dakinegabe117 · Jun 02, 2015 at 12:58 PM 0
Share

For some reason your CountDown Example Scene doesn't work. Could you please reattach it? Thanks

avatar image redeemer · Jun 02, 2015 at 04:30 PM 0
Share

Sure, but seems weird, I just downloaded it and imported in a new project and works fine. Please, could you be more specific about how the scene doesn't work? Like, it's loading and empty scene, or you don't see anything in your camera view, etc...

Here you have a new version with the anchors corrected (maybe you were not seeing the upper timer because it was way high if you were not using the same resolution I used).

https://mega.co.nz/#!egtSAQwT!twv_Hz5dJS4FXv6WThvl21Y$$anonymous$$tQC6oOwzxzSfFcdlj$$anonymous$$c

If there's any problem with this one too please tell me and I'll post the scripts and screenshots of the scene so you can build it yourself.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Start timer with trigger 1 Answer

Calling methods 0 Answers

Timer doesn't work properly 2 Answers

When Score goes up by 25 change timer value 1 Answer

Countdown Through a Label? 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