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 /
This question was closed Apr 14, 2013 at 07:35 AM by Fattie for the following reason:

Duplicate Question

avatar image
0
Question by skyerz · Apr 14, 2013 at 01:28 AM · cursorweaponkinect

How to create timer when selecting and deselecting items

I'm completely stumped with this current task, essentially, what i'm trying to do is. While i'm colliding over one item for more than 3 seconds i wish to pick it up. Then when to deselect, while i collide with another object wait three seconds to deselect it. This seems so easy when i type it but i'm not having any luck what so ever. I can select items fine, and when i do i have a script to highlight it in a different color, however when i wish to deselect it does it immediately without waiting hope this makes sense

 void OnCollisionStay(Collision Other)
 {
     
     //Debug.Log("the start time" + startTime + "the boolean"+ stool.pickedUP);
     if(Other.gameObject.GetComponent(typeof(TextControl)))
     {
         startTime+=Time.deltaTime;
         roundedRestSecounds=Mathf.CeilToInt(Time.time);
         
         progress = startTime *0.2f;
         
         CurrentState=true;
     }
     else if(Other.collider.tag==("Organ")){
         
         startTime+=Time.deltaTime;
         progress = startTime *0.5f;
         
         if(startTime>2.8f){
             stool.gameObject.BroadcastMessage("PickUP",Other.gameObject.name);
             //send message to deselect
             //or pick up = false
             //have plaeable here
         }//the only way we can test for colliding with something else is by checking if the last is the current
         if(stool.lastSelectedTool.name!=Other.gameObject.name){
             changeTime+=Time.deltaTime;
             if(changeTime>2.8f){
                 stool.gameObject.BroadcastMessage("PlacedDown",Other.gameObject.name);
             }
         }
     
         
         
     }
     /*
     else if(Other.collider.tag==("Placeable")){
         
         if(!stool.pickedUP){
             
         }
         if(stool.pickedUP)
         {
             progress = startTime *0.5f;
             //if start eceeds certain number
             if(startTime>6.0f)
             {
                 stool.putDown();
             }
             //you coud from this point send a message
             
             
         }
         
     }*/
     else{
         
     }

         
 }
 

Above is my collider withing my player class, this works fine with regards to selecting an item, however when i want to place it places it down immeidiatly. This is probably due to the face that changetime doesn't change back to 0 unless you exit the collision. could someone please help in getting my timer working correctly

 void OnCollisionExit(Collision Other){
         startTime =0f;
         progress =0f;
         changeTime=0f;
         
     }
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 Fattie · Apr 14, 2013 at 07:35 AM 0
Share

thousands of excellent questions on here about timers, search Invoke() etc. also unityGE$$anonymous$$S.com

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

12 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 avatar image

Related Questions

Comparing two GameObjects to pick up items 1 Answer

Custom Cursor with Kinect Wrapper 1 Answer

Kinect Hand Smoothing 0 Answers

How To Assign An Animation When Firing Weapon? 1 Answer

pause for dastardly bannana 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