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 07, 2013 at 08:12 PM by Fattie for the following reason:

Duplicate Question

avatar image
0
Question by nxt234 · Apr 07, 2013 at 05:30 PM · timers

How do I make an Ai shoot every 3 seconds?

I'm working on a game with a friend and I'm having trouble making the Ai shoot every 3 seconds.

Comment
Add comment · Show 7
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 07, 2013 at 08:12 PM 2
Share

there must be ONE THOUSAND identical questions to this. it's too much, from now on they'll just be closed

TI$$anonymous$$ERS IN UNITY .. USE "INVO$$anonymous$$E()"

avatar image sdgd · Apr 07, 2013 at 08:14 PM 0
Share

ah but not everywhere says about invoke this is the 2. time I've heard about it and will start slowly looking in to invoke

thumbs up for closing and pointing the Q

avatar image AlucardJay · Apr 07, 2013 at 08:18 PM 0
Share

Fattie is the Ambassador for Invoke and InvokeRepeating, I'm really surprised you havn't seen that before now =]

avatar image Fattie · Apr 07, 2013 at 08:18 PM 0
Share

it's important to use "time" etc etc etc later in advanced program$$anonymous$$g

But for timers in Unity you simply use Invoke or InvokeRepeating

its just that simple.

It is inconceivable that you would have to f--- around with time, comparisons, loops etc in a game engine .. to make a trivial timer

The whole issue drives me freaking nuts.

avatar image Fattie · Apr 07, 2013 at 08:34 PM 1
Share

Invoke( "go bonkers!", next time you see a timer question );

Show more comments

1 Reply

  • Sort: 
avatar image
3
Best Answer

Answer by cdrandin · Apr 07, 2013 at 06:29 PM

Basic Timer implementation

 float timer;
 int waitingTime;
 
 void Update(){
     timer += Time.deltaTime;
     if(timer > waitingTime){
         //Action
        timer = 0;
     }
 }
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 Toscan0 · Apr 12, 2020 at 10:32 PM 0
Share

Simple and easy xD

Just to improve, in this case: int waitingTime = 3

Follow this Question

Answers Answers and Comments

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

Related Questions

How Would I Change This To Read Within A Time Range? 1 Answer

turret firing delay timer? 2 Answers

How to Count quited(program off) time 1 Answer

Tell me about timing in Unity 0 Answers

Start Something on Main Scene Start Up 0 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