Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by ChristmasEve · Mar 17, 2018 at 05:58 PM · animatoranimator controlleranimationclip

AnimatorOverrideController not working

I don't know if I'm using this right. I have an animation controller with many clips in it. But there are a few exceptions where I might want to replace the idle clip with something else, or the idle and combatIdle clips with something else, but I'm just trying to get one to work for now. The important thing is that all clips that make a transition back to idle will make their transition back to the replaced clip. In searching for a solution, I came across the AnimatorOverrideController, which seems like it's supposed to do EXACTLY what I need. However, in testing, all models with the replacement controller still use the old idle. I tried a few different things:

 //assuming animCont is my main animation controller
 var anim=obj.GetComponent<Animator>();
 var overCont=new AnimatorOverrideController(animCont);
 overCont["idle"] = Instantiate((AnimationClip)Resources.Load("anim/guardidle")); //this resources load isn't null; it does load a clip so that's not the problem
 //overCont[overCont.animationClips[0]]=overCont.animationClips[1]; //I've tried this too, idle is in position [0], but when I did this, idle didn't become the second clip at [1].
 overCont.name="guards";
 anim.runtimeAnimatorController=overCont;

When I do it by name, as above ["idle"], I wasn't sure if it needed the name of the clip or the Motion (as defined in the animation controller) so I tried both and neither worked. idle is the motion name and longidle is the clip name. And, of course, specifying the clip instead of search by name didn't work either (commented out above). Nothing has any effect whatsoever. I'm using Unity version 2017.3.0f3.

Any ideas? Thank you!

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 hexagonius · Mar 17, 2018 at 08:11 PM 0
Share

before helping here code wise... why don't you create the override controller in the project view, assign it the actual controller, modify the clips you want changed and then assign it to the models you need it on? resources folder is used for small files and especially for files you might not use, but it sounds like you definitely do.

avatar image ChristmasEve hexagonius · Mar 17, 2018 at 09:52 PM 0
Share

I kind of mislead people by referring to "models" above. In reality, my human characters are dynamically generated. Just certain types of humans will have different animations (like guards in this case). I get what you're saying about creating the override controller at design time though. I'll try that and use that controller ins$$anonymous$$d (for guards) and see if that works. As long as I can, then, modify the base controller and the changes will take effect in the override controller for guards without me having to change both every time. There will be more than two in the end so I don't want to have to maintain a bunch of different animation controllers when they only vary slightly. I really should be able to do this all programmatically. I'm not sure if I'm running into a Unity bug here or not. I'll let you know if I get anywhere.

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

84 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

Related Questions

Animator not playing a playable 0 Answers

How to reset the animation after a gameobject is deactivated in Unity? 1 Answer

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

End of animation with animator. 0 Answers

How to synchronize child animation with parent ? 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