I thought I would share some tips and techniques I have come up with over several projects on some helpful ways to use puppet style animation rigs in Unity using just the tools and features in Unity. There certainly are great extensions (Smooth Moves), and third party apps (like Spine), and those will work very well depending on your needs.
My needs were to have something native and leveraging built in features. While given some level of control for animators, and the ability to essentially retarget and control certain aspects externally. Here are some of tips and methods I use to do that:
Setting up rig that allows for flexibility and a type of retargeting.
Typically when you set up your animation, you structure things hierarchically and animate those pieces directly. That becomes a problem if you need to change the pieces or access/modify them dynamically. Since this particular character/animation will need part modification and access, I have structured with empty Transforms for the parts I will be animating. Like this:
I try to use descriptive and generic names, this helps keep things clean and non specific. (and easily reusable)
I have also placed an empty object as a child of each called “—sprite”, in that folder is where I will place the actual sprites. The sprite folders are centered on the parent.
Additionally I used gizmo lines to simply draw lines to the parent. These aren’t really important, but they can be helpful to visualize things.
Also, I added a custom icon to each parent container, you can do that from the inspector.
This is very useful. Icons are selectable, so you can click on them to select the proper node while animating. This helps prevent clicking on the wrong elements or the nested sprites. Additionally, since it is on a gameObject (not a sprite), when animating you can use the normal transform widgets.
Adding the sprites.
Typically, will use full image of the character behind it for alignment. I will then go through and place all the elements in the sprite nodes of each object.
Doing it this way means that you can simply align them the way you want. Since the pivot point is actually the node and not the sprite, you don’t have to go through and adjust the pivot point on all your sprites.
… adding the rest.
Note about names:
Since I am going to be doing skin switching, it is helpful to have common named elements for each of the skin elements. For the base, all the elements are prepended with “BASE_”. More on this later.
After all the elements are placed and set up, I will then adjust the z-depths. I do it this for better control. If I need to put this character in front or behind another character, I change the layers or order on all the parts via script and the whole character will be in front or behind other elements via sorting order.
Continued…