Search Unity

Animations from multiple prefabs in a single Animator

Discussion in 'Animation' started by Grafer, Sep 27, 2016.

  1. Grafer

    Grafer

    Joined:
    May 30, 2015
    Posts:
    19
    Hello.
    I have a project with 4 different prefabs for a main character (seperate prefab for every direction he's facing). And every prefab has its own animations (Idle and walking in that direction).

    Is it possible to merge it all in a single Animator? When I'm trying to use an animation from different prefab, it is using my current prefab's sprite's element, not the one it was intended to.

    Is there any solution?

    The only thing, I can think of is to create an empty object. Drag every prefab into that object and Add an Animator component to every prefab.
    The parent object would enable correct prefab and this prefab's animator would control the animation. Does it make sense?
     
    Last edited: Sep 27, 2016
  2. CloudKid

    CloudKid

    Joined:
    Dec 13, 2015
    Posts:
    207
    Yes, your solution sounds fine. However, are you sure you need a separate object for each directions? I'm sure there is a way that you can reduce the number and make your life easier. Can't you just change the scale for mirror?

    If your animations are in 2D, you should be able to use only one object and change its current sprite + play the direction animation.

    If you are in 3D, you should look for a tutorial on how to animate an humanoid.

    Something doesn't sounds right to your current approach.
     
  3. Grafer

    Grafer

    Joined:
    May 30, 2015
    Posts:
    19
    It is 2D character.
    I am just a programmer. My team gave me character's prefab where every character part (leg, arm, head, hand etc.) is a seperate child object and animations animate every part seperately.

    If it was just a animation sprite sheet it wouldn't be a problem.

    Anyway, I went with my solution and it works quite good :) I hope it is efficient enough. Thanks for your reply.