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 NBapp · Jun 25, 2012 at 10:08 PM · timercounteractivatetimed

Dual Timer Problems

Hello,

I have a script that I am working on that has a counter to enable an object however I can't find a way to make it object specific. As soon as the awake function is called the timer starts and I tried to connect it to and empty that connected to a timer as well a timer script as well but it won't disable object and shows no errors. My goal is to have perks that can be deactivated on touch and self timer reactivates it.

Here is the Script timer I am trying to create to work for individual object and children:

 var perk1 : GameObject;
 
 var perktimer1 : int;
 
 
 function Awake (){
            perk1.active = false;
                 
              }
 function Update () {
 
         perktimer1++;
      guiText.text = "Grow time: "+perktimer1;
 
              if (perktimer1 > 400){     
                  perk1.active = true;
                 
      }
             
  }
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
0

Answer by hathol · Jun 25, 2012 at 10:22 PM

I'd add the script to the Perk object itself and then use invoke ( http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Invoke ) for the reactivation. So something like this:

 var isActive:bool
 
 function Start()
 {
     isActive = true;
 }
 
 function UsePerk()
 {
     //do stuff
     isActive = false;
     Invoke("Reactivate", 10); // call the function Reactivate after 10 seconds
 }
 
 function Reactivate()
 {
     isActive = true;
 }
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 NBapp · Jun 26, 2012 at 04:54 AM 0
Share

Thanks $$anonymous$$, this is what I was looking for with way less script involved in the long run. Others may need to know that var isActive: boolean; may be required if i'm not mistaken in some cases. Cool thanks again $$anonymous$$.

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

How to change between scripts on trigger? 2 Answers

Timer gets executed in the wrong scene 1 Answer

Time Counter - up 6 Answers

counter but with textures? 1 Answer

countdown/countup timer 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