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 user-3653 (google) · Jul 17, 2010 at 03:59 AM · timetimerstop

Track time between

This is what i have setup so far, 3dtext with a box collider that says begin and another that says finish.

i would like to count the time it too the user to go from begin to end accurately

since Time.time starts as soon as the game begins, i would like to reset it to Zero when the player touches begin, and stop/ print the amount of time it took when they reached finish.

or create another system that can track the time from "begin" to "finish"

explained in another way: create a stop watch timer

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 StephanK · Jul 17, 2010 at 05:01 AM

When the player touches begin do this:

float startTime = Time.time;

to find out how long the actual game/round is running do this:

float curTime = Time.time - startTime;

Done.

Comment
Add comment · Show 5 · 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 user-3653 (google) · Jul 17, 2010 at 06:19 AM 0
Share

ok for my "begin", i wrote:

float startTime = Time.time; function OnTriggerEnter (other : Collider) { guiText.text = ""+startTime; Destroy(gameObject); }

for the "finish" i wrote:

float curTime = Time.time - startTime; function OnTriggerEnter (other : Collider) { guiText.text = ""+curTime; Destroy(gameObject); }

but it seems there is an error in the finish script and i dont know how to deal with it

avatar image StephanK · Jul 17, 2010 at 10:30 AM 0
Share

What happens? Are you destroying the gameObject that contains your guiText? I need to see your code to help you there.

avatar image user-3653 (google) · Jul 17, 2010 at 11:31 PM 0
Share

it tells me a semi colon has to be inserted after the word "float", here is the error......... Timer Begin.js(1,6): UCE0001: ';' expected. Insert a semicolon at the end.......here is line 1......float startTime = Time.time;

avatar image StephanK · Jul 18, 2010 at 12:45 AM 0
Share

in javascript the syntac is different. the line should read var startTime : float;

avatar image user-3653 (google) · Jul 18, 2010 at 02:03 AM 0
Share

WONDERFUL! thank you kind sir

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

1 Person is following this question.

avatar image

Related Questions

Accumulating deltaTime oddity 1 Answer

How to make a timer read to the .001 of a second 2 Answers

Minute Timer Issue 1 Answer

Time based scoring 2 Answers

Accurate timing while using timeScale. 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