• 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 Joshua Beeler · Oct 01, 2015 at 12:01 PM · animationmecanimmotionanimationstate

How to Change the Motion of an Animation State in an Animator Controller at Run-Time?

TL;DR - My goal is to author a single Animator Controller that can be used by multiple non-humanoid characters. Each character has a unique motion to play for each animation state and needs to assign the motion to the state.

That is, I wish to reuse all the logic of an Animator Controller, but the motions that will be played need to be unique for each character using the controller.

Can this be accomplished in the Unity editor or via script?

The long version:

My game has 30+ non-humanoid characters. All of these characters move through the same animation states (idle, move, jump, etc.) using the same logic (transitions, parameters, etc.) but have unique animations to play in each animation state. Ideally, I want to author a single Animator Controller to express the common animation state machine logic, then reuse this single Animator Controller by dynamically binding the character-specific motions to the animation states in the Animator Controller either somewhere in the Unity editor or at run-time via script.

Can this be done?

It does not appear to be possible via the Unity editor because each animation state explicitly binds to a motion to use in the definition of an Animator Controller. So if multiple characters use this Animator Controller, they will be playing the same animations as each other, which is not what I want. Furthermore, the motion property of an animation state does not appear to be accessible via script.

The only solutions appear to be:

  1. Author the Animator Controller, then create a duplicate controller for each character, setting the character-specific motions in the definition of each character's Animator Controller. (Needless to say, this is a horrible solution. It's error-prone and does not scale.)

  2. Write my own code to largely duplicate the functionality of the Animator Controller that will allow me to dynamically bind the motions to instances of the reusable controller logic either at tool-time or run-time.

Comment
Add comment
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

1 Reply

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

Answer by FelipeResende · Apr 20, 2016 at 06:16 AM

You can try study this: http://docs.unity3d.com/Manual/AnimatorOverrideController.html

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

35 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

Related Questions

Mecanim starter pack - strafing motions 0 Answers

Get an Animator state inside an AnimationEvent callback of the last frame 2 Answers

Animation state not transitioning at 100% 1 Answer

Accessing AnimationState in Animator 0 Answers

Why does this animator appear to occupy two states, but report only one? 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