Search Unity

How to combine multiple animations for your main character with mecanim?

Discussion in 'Getting Started' started by xdotcommer, Feb 9, 2015.

  1. xdotcommer

    xdotcommer

    Joined:
    Aug 20, 2014
    Posts:
    33
    I've been having trouble figuring out what to search for to find this answer.

    Essentially, what I want to do is use mecanim for a 2D character - run, jump, stand, etc. - while having the option of adding items "on top" of that character (a helmet, boots, etc.) at run time based on player power ups. I'm not necessarily trying to reskin the character - more trying to add animations on top of the character.

    I'm not sure if child game objects with parallel animations states is the way to go... I'm not sure if there's a way to control, at run time, which animation layers are shown... In short, I just don't know how this particular problem tends to be approached.

    Does anyone have any suggestions?

    Thanks!
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    Well, in the scene tree any GameObject will move along with its parent GameObject. So for helmet and boots you should be able to just add child GameObjects to the relevant GameObject nodes in your character. You might have to switch off optimisation on the skinned mesh to get the GameObjects to show up, but once you've got that you should be able to put the boots etc. in place and just turn them on and off as desired.

    That's assuming that the accessories are pretty rigid, though. If they need to deform along with the character motion then this probably won't be good enough, and you'll need to do something a little more advanced to synch up the animations.
     
  3. xdotcommer

    xdotcommer

    Joined:
    Aug 20, 2014
    Posts:
    33
    Ended up doing this with a combination of "Sync'd animation Layers" and Child Game Objects I could enable / disable.

    I did end up manually editing the anim files (YAML) to change the "path" from the root game object to the child game objects.

    Unfortunately, with the latest Unity update (4.6.2f1) I can no longer sync animation layers (even though I have Unity Pro).