Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Playing animations on multiple objects in the editor?

Discussion in 'Animation' started by revraptor, Nov 9, 2020.

  1. revraptor


    Oct 30, 2015

    For my project I'm working on it was neccessary to cut my player characters object into it's base parts for the sake of animation/customization. So I have one main player gameobject that doesn't have any sprites, then I have child gameobjects for the arms, tool, legs, body, etc. I do this because otherwise I'd have WAY too many sprite animations to be reasonable, character customization wouldn't work how I want, and neither would equipping armor and the likes. This also makes my entire animation system modular when it comes to what I can or can't achieve during runtime (Instead of not being able to ToolSwingRight when crouching because I never manually animated that it just works, because I have ToolSwingRight and crouch for seperate parts.)

    When it comes to what tools the player is using I then use an animation override controller to swap out the animations depending on whats equipped, but I don't think that's relevant here.

    This has all been doing well and good, and it has achieved exactly what I wanted, but today I ran into a pretty big roadblock (that I did expect to run into to be fair.) I'm trying to add new equipment to my game, and this means creating new animations. I thought that I had done what I needed before cutting my player up, but plans always seem to change.

    Where I've been having the biggest issue is getting stuff to line up. I'm working on making a sort of broadsword swing animation, which means I need to animate the arms, and the tools child gameobject. Everytime I think I like what I have though I run the game and play the two together, and the tool just doesn't quite line up with the players hands (The arms are animated based on a spritesheet wheras the tool has it's transform animated.)

    So what I'm wondering-- Is there a way to get two different animations to preview at the same time in the editor?
    If it helps I control the animations during playtime by having each child gameobject have a script attatched that fires the appropriate triggers and sets the appropriate parameters whenever I trigger an event. I haven't written many editor scripts so I'm not sure if that helps or doesn't work. Ideally I could do it by just clicking some buttons in the editor but I don't see way to do that.

    Thank you for any advice or tips!

    I should clarify that each child gameobject has it's own animation controller. Originally I had each child gameobject animated from the parent gameobject, but this started falling apart when I implemented tools and weapons. I have way too many of them to not use animation override controllers (since I want them to be unique,) and my animation overrides system was becoming a nightmare. Especially with some weapons where I want the even more parts to animate along with them. Instead I settled on a system that I feel is relatively elegant where each child gameobject has different parameters for (IsUsingToolUp, IsSwingingToolUp, IsLiftingToolUp, etc, all representing different possible ways to use a tool/weapon), and then I swap those out with animations references from scriptable objects that are held in the weapon itself. I've been loving the way I got this working up until this point where I'm having a hard time visualizing new animations as I work on them.
    Last edited: Nov 9, 2020