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 ShinyTaco · Feb 08, 2013 at 04:09 AM · variabletimerint

How to Reset Score and Variable Problem?

Hey everybody,

Please look at my code. Basically what I'm trying to reset delayTimerStart to 0 while continually adding delayTimerStart to newDelayTimeTotal

I understand that it is resetting to 0 because of newDelayTimeTotal = delayTimerStart;

Any help is greatly appreciated.

Thank you in advance.

Apologies about the post, it was stuck in code mode.

function stopDelayTimer () {

     newDelayTimeTotal = delayTimerStart;  // <-- I'm sure the problem is here
 
         //We Call delayTimeTotalAdd Here
     }



 function Update () {
     
     delayTimerGUIdisplay.text = "SCORE " + delayTimerStart;
     delayTimerStart ++; //Our Timer Starts when the Player is not grounded *Works*
 
 }



 function delayTimeTotalAdd () {

         //This works and keeps adding up    
         delayTimeTotalScore.text = "TOTAL " + delayTimer.newDelayTimeTotal; 
        //How Do You Reset delayTimer without resetting delayTimer.newDelayTimeTotal to 0
 }
Comment
Add comment · Show 4
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 iwaldrop · Feb 08, 2013 at 05:35 AM 0
Share

I don't understand what's happening here, what the initial values of your variables are, or why you're trying to add a value that you are setting to 0 to anything at all. Is this a timer? Why not just do this?

 timer += Time.deltaTime;

And then, whenever you want to reset your timer, just to this:

 timer = 0;
avatar image ShinyTaco · Feb 08, 2013 at 07:31 AM 0
Share

That's the problem. I want to keep the first value of say 5 (which would come from delayTimerStart). I then want to reset delayTimerStart to 0 but add 5 to a new variable which is newDelayTimeTotal.

So, if I got 5 the first time and 4 the second time newDelayTimeTotal would be 9 and son and so forth.

Thanks.

avatar image MountDoomTeam · Feb 08, 2013 at 10:11 AM 0
Share

in start function make score total equals 0

In update function say: if (good thing happens){score = score plus 1}

if (reset thing happens) {score equals 0}

avatar image iwaldrop · Feb 08, 2013 at 09:28 PM 0
Share

You describe exactly what you're trying to do, and it sounds like your problem isn't exactly unity related, but rather generically storing values. To be honest, I think you're solution is overly complex, and you should take a step back and analyze the best way to solve your problem, then implement it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ShinyTaco · Feb 14, 2013 at 03:04 AM

in start function make score total equals 0

In update function say: if (good thing happens){score = score plus 1}

if (reset thing happens) {score equals 0}

This worked. Thanks.

Comment
Add comment · Show 3 · 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 iwaldrop · Feb 14, 2013 at 03:06 AM 0
Share

You posted a question about timers and your answer is about scores?

avatar image ShinyTaco · Feb 14, 2013 at 03:07 AM 0
Share

Yes. $$anonymous$$y score is based on a timer.

avatar image MountDoomTeam · Mar 27, 2013 at 03:50 PM 0
Share

in the reference the Time.time the function has a very good delay example http://docs.unity3d.com/Documentation/ScriptReference/Time-time.html

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

Variable data type for two ints (x and y) in inspector 3 Answers

Problem with variables,Problem with identifying a variable 2 Answers

How can i save a int for multiple texture. Please Read. 0 Answers

controlling the increment in the variable 1 Answer

I can't print a int.ToString() variable in a guiText.text 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