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 post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by lil_billy · Nov 19, 2012 at 04:45 PM · coroutinecoroutine errors

Coroutine Errors

So I'm writing this because I've recently crashed into this tree and hit every branch on the way down, and there is very little information about it here, this is for future reference.

First problem: Why is my coroutine running on old information? Ex:

startCo("x"); startCo("y");

x changes a variable and y was supposed to use that variable to do something

How a coroutine works is when its called it accesses all the information it needs to operate and saves at the START of its call. So if you start 2 coroutines in the same function /essentially the same time then all their relevant variables become locked within them before you get the chance to change the variables they use. so even if you spread it out over 30mins it still is using the same variables at the start of its call.

Second, How come this function is being called multiple times?

I'm not sure on the exact technical reason behind this but basically if you have a coroutine and accesses a lot of global variables on itself and externally, changes a lot of things externally (calling multiple function, changing variables), and especially instantiates something the chance for this bug increases and it is compounded by how long the couroutine is up for as well as the severity of any present lag during its operation. The biggest culprit is Instantiating an object and then say calling a constructor on the object. To overcome this bug you basically have to address these circumstances. even if there is no yield between an instantiation and constructor try moving that code to a new non coroutined function.

If there are any more hardcore programmers who can better explain this I have enabled this for community editing.

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

0 Replies

· Add your reply
  • Sort: 

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

9 People are following this question.

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

Related Questions

I can't start a coroutine. I get a weird message from visual studio 1 Answer

Had difficulties implementing intro to Coroutines from unitypatterns.com. Help? 1 Answer

Coroutine sequence not running properly 1 Answer

Coroutine not working - what I did wrong? 2 Answers

Why does this co-routine not function properly after re-entering the scene? 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