Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Tomer-Barkan · Jul 11, 2014 at 06:42 AM · animation2d2d animation

2D animations - same controller for different characters

Hi,

I have several playable characters, that use the exact state machine for the animations, but the animations themselves are different (different sprites). I was wondering if there was a way to use a single animation controller for all these characters, instead of duplicating it and changing the "motion" component of each state?

Thanks

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

4 Replies

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

Answer by Tomer-Barkan · Mar 12, 2015 at 01:49 PM

Half a year later I can answer my own question. Not sure when this feature was added, but there's now a Animator Override Controller component which can be created in the project. This allows you to select an animator controller (state machine), and set different animations for each state, but maintain the same transitions and properties.

Neat.

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 plagas36 · May 12, 2016 at 02:12 PM 0
Share

Hey $$anonymous$$er, I've done an asset that could also help people with this kind of problem. It help me so much with me game development. It duplicates an animator and then replace all clips automatically. States and transitions are kept during transfer.

You can even copy events and curves even if clips have different durations.

I'll just link an example video with a 2D characters : Example

General presentation with events and curves : Presentation

avatar image Tomer-Barkan plagas36 · May 12, 2016 at 07:55 PM 0
Share

I had a few of these tools too, but the big problem is that if you want to change something, you need to change it all now. Anyway, like I said the AnimatorOverrideController does the trick so no need for any hacks anymore.

avatar image
0

Answer by KMKxJOEY1 · Jul 11, 2014 at 01:35 PM

No, I'm pretty sure you need to have a different controller for each animated object. Like you said, each state in a controller is linked to 1 motion/animation slot

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 ruby589 · May 17, 2016 at 12:38 PM

No!Different controller for each animated object maybe better!

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 N1NNIE · Dec 31, 2020 at 12:36 PM

I watched a brackeys video about animations and I put in a piece of the code and gave me tons of errors. Can you help why this is happening. Here is the code:

 if (Input.GetButtonDown("Crouch"))
 {
     crouch = true;
 } else if (Input.GetButtonUp("Crouch"))
 {
     crouch = false;
 }
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 N1NNIE · Dec 30, 2020 at 05:56 PM 0
Share

Also, it said theres something wrong with the equal sign and type errors. Its a hideous blur. If you want the entire code here: using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Player$$anonymous$$ovement : $$anonymous$$onoBehaviour { public CharacterController2D controller; public Animator animator;

 public float runSpeed = 40f;

 float horizontal$$anonymous$$ove = 0f;
 bool jump = false;

 // Update is called once per frame
 void Update()
 {
     horizontal$$anonymous$$ove = Input.GetAxisRaw("Horizontal") * runSpeed;

     animator.SetFloat("Speed", $$anonymous$$athf.Abs(horizontal$$anonymous$$ove));

     if (Input.GetButtonDown("Jump"))
     {
         jump = true;
         animator.SetBool("IsJumping", true);
     }
    
 }

 if (Input.GetButtonDown("Crouch"))
 {
     crouch = true;
 } else if (Input.GetButtonUp("Crouch"))
 {
     crouch = false;
 }

 public void OnLanding ()
 {
     animator.SetBool("IsJumping", false);
 }

 

 void FixedUpdate()
 {
 
     controller.$$anonymous$$ove(horizontal$$anonymous$$ove * Time.fixedDeltaTime, false, jump);
     jump = false;
 } 

}

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

25 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

Related Questions

How to make a proper walk animation cycle? 0 Answers

,Is there a Way to Flip 2D-Keyframes? 0 Answers

how to make 2D sprites skeletal Movements 1 Answer

2D Animations Not Working After Building Game 1 Answer

First Frame of 2D Animation Ignored? 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