In my last Toon Boom Harmony blog post, I discussed how you could import Harmony sprites into your Unity project using Harmony’s middleware toolkit. While that workflow is relatively simple for getting a sprite into Unity and playing a looping animation, it is not so simple for controlling your sprite’s animations. In this post, we’ll look at how we can import our animations from Toon Boom Harmony and use them with an animator controller in Unity. We will cover Harmony Essentials, Advanced, and Premium workflows.
What is an Animator Controller?
I recommend referring to this blog post from last year if you do not know what an animator controller is. To summarize, an animator controller is a state machine that allows us to fire specific animations when a specific event occurs. They are incredibly helpful in allowing us to create characters in a game whose animations are dynamic.
A simple example of why an animator controller is useful is if we look at making a character move in a top-down 2D game. When a character moves, we want to be able to use any of these animations: walk left, walk right, walk up, walk down. An animator controller will allow us to easily create this behavior. We can create triggers for each of the states. In our movement script, whenever a character changes their direction, we can fire off the associated trigger to make the animation play.
Moving Beyond Middleware Workflow
The previous workflow for importing a sprite and animation into Unity is simple. The problem, however, is that, when we use this workflow, our animations are imported as xml files. There is not a user-friendly way of parsing XML files to create animations in Unity. It would require a decently involved script to happen. Further, even though the Harmony middleware provides a script for us to play an animation from the XML, it does not create a .anim asset file for us. Animator controllers rely on .anim files to be able to create their state machines.
Ultimately, what this means, is that the middleware workflow is great for importing sprites and animations that will not be changing. This would make the middleware workflow useful for things like background sprites and animations. Essentially, static objects in the scene that will not be cycling through multiple animations. For instance, if we had a windmill in our background that’s constantly rotating. The middleware would be great for importing and implementing that asset. For playable characters, however, we need more control over the animation states and, unfortunately, the middleware solution does not currently provide the level of control we need.
Watch the below video to learn the workflow. Unity 5 or higher is recommended. I am using Unity 2017 in the video.
Now that you know a way to bring your animation frames into Unity, you can start creating dynamic animations in your game based on your amazing Harmony animations. Considering the plethora of powerful tools in Harmony and Unity, you should now be able to create beautiful, full-featured games.
Share this Post