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
0
Question by HauntedBees · May 05, 2016 at 06:50 AM · animationscripting problemanimation controller

Changing Animator Controller Animations Via Script

If I have multiple game characters that all have the same types of animations (idle, walking, jumping) and each one has different animations (HumanIdle, HumanWalk, MonsterIdle, MonsterWalk, etc), do I need to create a separate Animation Controller for each of them, or is there a way to create one Animation Controller with Idle, Walk and Jump states defined, but with the actual animations they point to being changed programatically?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jason2014 · May 05, 2016 at 07:52 AM

You are creating one Animator Controller, to control all of them. I don't know if you are creating a 2D or 3D game, because they have much difference in configuration. Have you heard about "Blend Tree"?

Blend Trees

This special feature allows to control all of animations in one. For script control you have to add parameters in animator first and then by scripting you need to change values. This is too complicated to explain in answer, so check this videos: Player Animator Controller

and this: Writing the Player Script

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 HauntedBees · May 07, 2016 at 12:31 AM 0
Share

I'm creating a 2D game, and I've been using that roguelike tutorial for reference, but it also highlights the issue; different animation controllers were made for both the player and the enemies, even though many animations were shared between them (PlayerIdle, EnemyIdle, Enemy1Idle are all "idle animations").

$$anonymous$$y goal is to ideally have just one AnimationController and then, say, in the Player's script say "the Player GameObject's AnimationController's idle animation is PlayerIdle, moving animation is PlayerWalk, etc."

avatar image
0

Answer by incorrect · May 05, 2016 at 01:39 PM

I also would like to mention new Playable API.

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

Answer by plagas36 · May 12, 2016 at 02:51 PM

I think you'll have to create multiple animator controller.

I've just made exactly what you need. I got the same problem a few days ago.

Check out this asset : Example

Also, it can do a lot more than that. It can copy curves and events that you've put on an clip on another one. Perfect if some of your characters get the same events and cuves for the same kind of animations.

I show an example here : Example

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

6 People are following this question.

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

Related Questions

flipping animation (I know this is asked alot) 0 Answers

I need help with my animations and script 0 Answers

How can I use IK with AnimationClipPlayable or AnimationMixerPlayable? 1 Answer

How do I stop moving when attacking? 1 Answer

Can I make animations snap to a frame? 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