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 youngapprentice · Mar 14, 2015 at 01:40 AM · rotationcoroutinelerp

'Clear' a Coroutine?

Hi, all!

Running a rotation script in a coroutine. It saves the rotation of an object at the beginning, then loops through some leaping code, then snaps the rotation to the previous rotation plus desired degrees for good measure.

This always works the first time.

After that, on the snapping step, my object rotates to the orientation it was in after the first trial. My theory is that the coroutine is somehow holding on to the local variables that are set before the loop, and not 'clearing' them even when StopCoroutine() is called.

Am I doing something wrong here? Feel free to ask for example code if I am being unclear.

Cheers! - YA

Comment
Add comment · Show 2
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 ReeRoo · Mar 14, 2015 at 02:17 AM 0
Share

Could you post your code? will be able to get a better idea of whats going on.

avatar image youngapprentice · Mar 14, 2015 at 02:23 AM 0
Share

For sure. I'll edit my question now.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Owen-Reynolds · Mar 14, 2015 at 03:36 AM

I'm pretty sure locals in coroutines work just like regular locals. Print it and see. Think it's just bad code somewhere.

I am seeing firstRot.x on line 23, which is the unknowable quaternion value which should never be used (missing eulerAngles.) But I think, instead of even eulerangles, transform.rotation*Quaternion.Euler(0,0,degrees); is nicer.

But that error should make it wrong all the time, even the first time.

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 youngapprentice · Mar 14, 2015 at 03:55 AM 0
Share

I stand corrected. It seems the issue did lie in me getting mixed up in my Quaternions vs Eulers. This is odd to me because the code worked almost completely as expected. I thank you for pointing out this issue and will put up the finished code.

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

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

Related Questions

rotate object by list values 0 Answers

better way to rotate instead Coroutine 1 Answer

How to use the lerp function with rotation? (C#) 1 Answer

How to ROTATE an object without slowing the ends (lerp) 3 Answers

Lerp 180 degrees while holding B and lerp back 180 degrees when let go of B. 2 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