Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
3
Question by jimmyinapiece · Feb 24, 2015 at 07:45 PM · mecanim

Problems with Animator when disable/enable gameObject

I have a turret enemy that have a animator that always play a idle animation on it. The idle animation is just some of the top parts of it moving a little. I also have a turret script that is using the turrets 'turret_rotation joint' to turn the top of the turret around so it can look at the player. It works well with the turret turning around and tracking the player. I can select the joint in the editor and if i rotate it myself the turret will rotate from the new angle. So the animation to not clash with my turret script.

If i then disable the turret in the editor and then enable it again things break down. The turret keeps playing it's animation but it no longer rotate. If i select the joint in the editor and try to rotate it no longer works. The turret will remain stuck in the rotation direction it was at when i disabled the turret. If i turn off the animator component the turret will start to rotate again but will not animate anymore. Turning the animator back on will snap it's rotation back to the pre-disable rotation and it will resume animation.

Anyone has had problems like this when deactivate/activate of object seems to mess up the Animator. Seems to be a bug with it's mask or something as it starts to animate one of the joints it should not touch. With an old value also :(.

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 meat5000 ♦ · Feb 24, 2015 at 05:35 PM 0
Share

Add

 function OnEnable()
 {
     Start();
 }

or its C# equivalent.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ProgrammerSi · Oct 25, 2016 at 11:17 AM

I too have this problem. In Unity 5.3 and now in 5.4. Any word from Unity on this?

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 ProgrammerSi · Oct 25, 2016 at 07:00 PM 0
Share

I managed to successfully work around the problem, i'm pretty certain it's a Unity bug now. The difference between the joint transform before and after it has been disabled/enabled again is that before this it retains the previously set transform. Afterwards it reverts to the transform in the animation pose every time.

It is possible to work around this by flagging that you have disabled the component in OnDisable. And if so handling the rotation differently. Before it has been disabled do what i assume you were doing which is increment the transform by however much you want it to rotate. After it has been disabled/enabled you want to keep a total rotation yourself and always apply this every time.

One thing i have noticed is that this seems to occur when using a mask on the animations. Both the objects i have this problem with use a mask, i believe we have other cases without masks that work normally. Hopefully that will alert some Unity devs.

avatar image Develax ProgrammerSi · Feb 19, 2020 at 03:38 PM 0
Share

Still have this bug in 2020 in Unity 2019.3.0f5

avatar image
0

Answer by dcdkiller · Aug 20, 2018 at 11:07 AM

You can reset the rotation before deactive, when you active it again ,it works.

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 Ommand · Feb 25, 2021 at 01:25 PM 0
Share

I still have this bug on Unity 2020.1.15. What do you mean by "reset rotation"?

avatar image Develax Ommand · Dec 01, 2021 at 01:11 PM 0
Share

Reset it via code in the OnEnable method. Set it directly to default.

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

8 People are following this question.

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

Related Questions

Animations become faulty when imported into Unity 2 Answers

Mecanim bool parameter is staying true for too long 2 Answers

How to edit a Mecanim animation for your character? 1 Answer

how to make ghostcharacter(enemy) crawl on sidewalls and walk on upper wall inversley??? 2 Answers

After 180deg turn animation, char is at ~160 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