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
3
Question by BluesyPompanno · Apr 07, 2018 at 01:26 PM · animationanimatoranimator controlleranimationsanimationclip

How to reset animator controller ?

Hello. I hay a question regarding animations,animation controllers,animators Is there a way how to "restart" animatorcontroller ?


For example :

If i have 2 guns with their own animations and animator controllers and switch betwean guns. One gun gets disabled and the other gun gets activated the animations gets stuck in weird position/rotation.


So is there a way how to restart the animator so animations would play normally without weird po sitions/rotations.


I have tried - creating a boolean and forcing the animator to play the 1st animaton ( taking gun out )
- disabling the animator and reactivating it - destroying the animator component and creating it again ( didn't work probably wrong setup) - I have also tried the Animator.Rebound() -don't know how but it didn't work Anybody knows how to fix this ? - I have also heard about deleting animation defaults or something like that ( didn't tried - don't know how )

I am using Unity 2017.3

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 PZ4_Bailey · Jun 20, 2018 at 05:55 PM 0
Share

Hi, is there no solution to this yet?

4 Replies

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

Answer by Feelnside · Jun 20, 2018 at 06:04 PM

Probably the best way it's just start the idle animation after the switching a gun. For example:

 anim_gun.Play("idle", -1, 0f);
  • 'idle' is your animation which should play

  • '-1' is the layer, -1 means default (first)

  • '0f' is start time of the animation

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 impurekind · Sep 23, 2018 at 11:15 PM 0
Share

This simply does not work for me.

The actual animation controller says the Idle animation is playing but the gun in still showing whatever animation position/frame it was on when the object was deactivated, and the Idle animation is simply playing over the top of that pose. So the animation is still essentially broken.

It's pretty much a Class A bug from what I can see, as there is apparently no way to properly wipe the stuck animation pose other than to reset the level entirely.

Unless you have any other suggestions?

avatar image kevojo impurekind · Sep 24, 2018 at 06:44 AM 0
Share

I was having the same issue earlier. Specifying the normalizedTime as zero is supposed to force the animation to start from there, but it doesn't. Oddly enough, it used to in older versions of unity. I think it's like you said, a class A bug. Animator component has been very buggy for as long as I can remember.

avatar image
17

Answer by sarahnorthway · Jan 21, 2021 at 05:22 AM

This works for me, at least for a simple case. It returns the AnimatorController to the Entry state:

 Animator anim = gameObject.GetComponentInChildren<Animator>();
 anim.Rebind();
 anim.Update(0f);
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 unity_v7q2Q0bQ9s7CtA · Jun 01, 2021 at 12:57 AM 0
Share

It worked for me, thanks Sarah.

avatar image SimoensS · Jul 14, 2021 at 01:33 PM 0
Share

This was exactly what I was looking for. Thanks Sarah!

avatar image
4

Answer by impurekind · Sep 23, 2018 at 11:39 PM

This isn't the solution but there REALLY should be something as simple as Unity having some in-built function that when you use gameObject.SetActive(false); you can also select to save the object's states or not. And then when you reactivate the object it will either be reset completely or be in exactly the same states it was when you deactivated it. It really should be THAT simple, something like gameObject.SetActive(false, true); with the first argument saying if it's going to be activated or deactivated and the second saying whether you want to save all its states when deactivated or not. So if I set it to false, false then when I reactivate my gun every single thing about it will be back to the default state, on all its components and children and their components too. I mean, maybe I'm simplifying it, but you get the point.

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 GMBLO · Feb 23 at 02:35 PM 0
Share

Animator.keepAnimatorControllerStateOnDisable = true;

avatar image
0

Answer by canyon_gyh · Apr 22 at 09:14 AM

I think need SetActive(false) for Animator When want to Play ,First SetActive(true) , Second anim.Update(0f); anim.Play("idle", -1, 0f);

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

224 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 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

How to get reference to a specific Animation Clip in Animator. 0 Answers

How to interrupt and replay an animation? 0 Answers

Mirroring animation clip without mirroring root motion node? 0 Answers

Hiding non-public functions from Animation Event Window? 0 Answers

Animator Override Controller changed at runtime doesn't always play the animations correctly 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