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 May 07, 2013 at 12:16 AM by Julien-Lynge for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by Perrymanon · May 07, 2013 at 12:14 AM · waitforsecondsienumeratorreloadreturnyeild

WaitForSeconds before reload not working?

Hello, i am working working on a shooter and I need the game to wait for a few seconds, say 5, when the reload command is pressed to give time for my reload animation to play. I am trying to use the code below, which i constructed after consulting the scripting reference and a few other posts in the forums, but it does not work, I don't get any error messages but the game just reloads instantly without raking notice of the delay. Any help on this would be greatly appreciated, Thanks you.

Jack

Here is my code.

 void Reload()
     {
     reloadtimer(5.0f);    
     Player.GetComponentInChildren<PlayerAmmo>().clipsize = Player.GetComponentInChildren<PlayerAmmo>().clipmax;
     Player.GetComponentInChildren<PlayerAmmo>().AmmoCount -= Player.GetComponentInChildren<PlayerAmmo>().clipsize;
     }
     
 
     IEnumerator reloadtimer(float delay)
             {
               yield return new WaitForSeconds(delay);
     
             }
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

  • Sort: 
avatar image
0

Answer by Julien-Lynge · May 07, 2013 at 12:15 AM

FYI, UnityAnswers (UA) is not Quality Assurance (QA) - it is up to you to write and bugfix your own code. We're more than willing to help you learn Unity, so please start with these resources and do a bit of research on your own:

Please check the documentation for IEnumerators and the documentation for StartCoroutine, which you will need to understand and use. You are not using IEnumerators correctly.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

13 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

Related Questions

IEnumerator manipulates variable in android build 1 Answer

Proper Way to Wait in C# 1 Answer

WaitForSeconds Not Working [SOLVED] 2 Answers

Return without Break 1 Answer

yield return new WaitForSeconds () not working 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