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 DavidCoder · Jan 31, 2012 at 11:41 PM · timerwaitforsecondshealth

,Pause/stop timer (waitforseconds)

Hi people, i doing a script that when the character jump a timer starts to verify if he is in the air.. if he'r in the air for more than 2 secs it takes out 10 of hp... the problem is that when i press space the timer starts, and if a press many times in a row the timer starts verious times.

when that happens, its normal that when one of the many timers that start checks that im in the air.... what i want to do is like [code]

 if(Input.GetButton("Jump"){
 "code to stop the timer"
 hptira();
 }
 
 function hptira(){
     if(jumping)
     {
         
         if(curHealth >= 1)
         {
         curHealth -= 10;
         }
         if(curHealth == 0)
         {
         Application.LoadLevel(3);
         }
     }
     else{
     }
 }

[/code]

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 syclamoth · Jan 31, 2012 at 11:42 PM 0
Share

Well, if you already have something to stop the player from jumping multiple times in mid-air, why not use that?

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by TripodGRANNE · Feb 01, 2012 at 02:06 AM

Try this:

  if(!jumping && Input.GetButtonDown("Jump")) {
       "you should use a code to start the timer if they jumped"
       "if they are already jumping the timer should be already counting down"
   hptira();
   }
 }

 function hptira() {
 
 var timer = 2.0; // set timer to 2 seconds
 timer -= Time.deltaTime; // subtract from timer with seconds

    // you also need code to check if they landed back on the ground
    if(landed) {
      // code to stop timer and stop running code
    } 
    else if(timer <= 0.0) {

        curHealth -= 10;
    }
 }
Comment
Add comment · Show 1 · 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 DavidCoder · Feb 01, 2012 at 03:06 PM 0
Share

$$anonymous$$ANY THAN$$anonymous$$S! i was searching for this :D

avatar image
0

Answer by DavidCoder · Feb 01, 2012 at 12:07 AM

What i want is that when i pres the space the timer stops, cuz now when i press space it starts another staying in sceane 2 timers.,The problem is that i want to stop the timers when i press the space again... cuz this way it keeps starting the timers all over again

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 syclamoth · Feb 01, 2012 at 12:08 AM 1
Share

Either post this as a comment, or edit your original question.

avatar image DavidCoder · Feb 01, 2012 at 12:12 AM 0
Share

but you can help me? or not?

avatar image AlucardJay · Feb 01, 2012 at 12:53 AM 2
Share

people here can help, but to know how - you have to be clear. your first question answer is if((Input.GetButton("Jump")&&(!jumping)) , your second question I cannot even understand. RE-EDIT YOUR QUESTION, only post in the comments, don't write in the answer space for your own question.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

how do I make a Time Based Score System? 1 Answer

Debug log doesn't always activate? 1 Answer

Not identifying the collider? 2 Answers

Wait in seconds before damaging the player again 2 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