Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
4
Question by lonelycamper · Jul 15, 2017 at 11:21 PM · animationbugbug-perhaps

Animation bug while disabling and re enabling.

Hello i'm using the animator component but when I disable it and re enable while the animation is playing the object stays where it was first disabled and doesn't go back I did a little bit of research and people say this is a bug So? is there anywhere around this then?!?

I would send a image of what it looks like but Unity's website glitching out rn ill post asap if needed.

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 Andrey-Postelzhuk · Aug 16, 2018 at 11:34 AM 0
Share

Are you calling Rebind() function? $$anonymous$$aybe this will help: https://forum.unity.com/threads/losing-animator-state.307667/#post-3598984

4 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by OUSS23 · Aug 10, 2018 at 10:45 AM

You need to make sure you added keyframes for all of your animated properties in each animation clip, otherwise, this is a tricky solution:

  1. Create an empty state in your animator controller, its name by default is "New State".

  2. Make sure the "Write Defaults" is on for that clip.

  3. Do this whenever you want to disable your GO:

    anim.CrossFade("New State", 0f);

    anim.Update(0f);

    anim.Update(0f);

    gameObject.SetActive(false);

While "anim" is your Animator.

It works on Unity 5.x if you still have problems, try called anim.Update(0) 3 times or more.

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 UsefulYdyot · May 18 at 01:29 AM 0
Share

This works well! Thank you so much! Btw, in my case it worked in the OnEnable-method. And only with one call of anim.Update(0f); (Unity Version 2020.1.2f1)

avatar image
0

Answer by Dudicus · Jul 16, 2017 at 12:02 AM

This may be a bug. But you might be able to avoid it by instead of disabling and enabling the component, stopping and starting the animation in the component.

https://docs.unity3d.com/ScriptReference/Animation.html


Animation.Play and

Animation.Stop

Comment
Add comment · Show 2 · 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 lonelycamper · Jul 16, 2017 at 12:06 AM 0
Share

Sorry if this confused you I didn't mean to say animation meant to say mechanim animator. Or unless mechanim has animation.play and stop

avatar image Gabsparks · Jul 24, 2018 at 04:28 PM 0
Share

I have the exact same bug. Sadly I can't just stop the animation, because my GameObject has to disappear from the screen (and the Animator component aswell). When it come back enabled, the default state of the animation is never reached on screen, even though in the Animator window shows like the animation is on the "correct state". This just happens if the Animator disappear when the animation is been played in a state different than the "inicial default" state. I don't know if helps, but this bug SEE$$anonymous$$S to occur also when animate a transition between two states where "Write Default" is disabled. I just don't know what to do to solve this and this bug (if this is really a bug, not something that I'm missing) is delaying my progress on my project.

avatar image
0

Answer by ProgOrion · Jul 18, 2017 at 11:31 PM

I have the same bug, unfortunately. Although, it has some randomness because I wasn't able to reproduce it in a smaller test scene with two cubes.

Generally, more complex stuff doesn't like being activated or deactivated in Unity. This is just another bug in the long list.

Comment
Add comment · Show 3 · 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 ProgOrion · Jul 18, 2017 at 11:33 PM 0
Share

Oh, just mentioning, that the legacy Animation component doesn't have this bug. There you can freely disable and/or enable animations.

avatar image Andrey-Postelzhuk · Aug 16, 2018 at 11:35 AM 0
Share

Have the same bug. Found a workaround to call Rebind() in a LateUpdate() https://forum.unity.com/threads/losing-animator-state.307667/#post-3598984

avatar image ProgOrion Andrey-Postelzhuk · Aug 28, 2018 at 10:21 AM 0
Share

Thanks for mentioning, maybe it will be useful to me later on!

avatar image
0

Answer by lorux · Sep 05, 2019 at 02:19 PM

I've found a potencial solution which can be found here: restoring hierarchy transform original state before deactivating animator

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

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

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

Related Questions

Animation load bug 0 Answers

Animation doesn't play but controller works correctly (Legacy issues) 0 Answers

Animation with minimum length? 1 Answer

Unity 4.5.2 bug changing the properties of the 2d colliders in animation 1 Answer

Scene loading time after upgrade from 5.5 to 5.6 4 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