2D Animation, Part 4 – Code Explanation
Posted: April 2, 2014 Filed under: 2D Animation, Guest Posts | Tags: 2d animation, animation, c#, character animation, code, csharp, game dev, mecanim, scripting, unity2d Leave a commentPreviously on the site we hosted a guest series on 2D animation in Mecanim written by game artist Jonathan Ferriter. In Part 3 of the series, Jon showed us how take our 2D animations and implement them in the Unity engine using the two scripts provided in the post and titled Jump.cs and Move.cs.
In that third video, Jon sort of skims through the makeup of these scripts and doesn’t take the time to explain how they actually work, so I wanted to write this post in order to discuss them further. While writing this post I’ve gone through both scripts, learned how they work, and written comments in them so you might better understand their systems. You can download the updated scripts from this link.
Guest_JonFerriter_2DAnimation
Read the rest of this entry »
Blend Trees: 1-D Blending
Posted: January 29, 2014 Filed under: 3D Animation | Tags: animator controller, blend, blend tree, c#, code, humanoid, mecanim, mecwarriors, scripting, unity3D 4 Comments“A common task in game animation is to blend between two or more similar motions. Perhaps the best known example is the blending of walking and running animation according to the character’s speed.”
— Unity Docs
What Is A Blend Tree?
A blend tree is a special type of animation node in Mecanim that allows multiple different animation clips to be played at the same time so that an animated object can shift between different motions. It allows us to maintain a smoothed state of motion in situations where a quick animation swap would otherwise appear jerky and visually inconsistent.
This smoothed motion is created when a blend tree takes a percentage of each animation involved in the blend and combines them into a single unique motion. The percentage of each animation that a blend tree uses in a blend is controlled by one or more parameters set in our Animator Controller. As the values of these parameters change, the percentage of each animation used in a blend is adjusted in real time.
In this post I want to show you how to set up a few basic blend trees of your own and discuss some situations where blend trees can really help out in your Mecanim development. Let’s go, Warriors!
Read the rest of this entry »
Humanoid Animation – Free Motion, Part 2: Modifying the Third Person Controller
Posted: October 28, 2013 Filed under: 3D Animation | Tags: animation, c#, csharp, mecanim, scripting, unity3D 17 CommentsWelcome back, Warriors! This is the second installment of my tutorial on building a free motion animation system using Mecanim. In this post I’m going to walk you through the steps for modifying the Third Person Controller (TPC) script that comes as a part of Unity’s Standard Assets so that it works with Mecanim.
If you haven’t read Part 1: Importing Assets, be sure to check that out before reading on. You’ll need the tutorial package from that post to continue working.
I mentioned this briefly in the first post, but I want to remind you why I’m showing you how to use the TPC script in this tutorial. Even if I’m not a huge fan of it, plenty of developers still use it in their project because it is immediately available to everyone as a part of Unity’s Standard Assets packages. It’s also pretty easy to use if you don’t have the time or know-how to write your own movement code. Unfortunately, the script is written with Unity’s Legacy animation system in mind and not Mecanim. This can cause a lot of problems during development, especially later on when you can’t change fundamental game systems like player movement.
Since I’ve been in this difficult position before, I intend to show you all a way to continue using the TPC script for player movement while using Mecanim for character animations. In order to merge the two systems, we’ll need to make some modifications to our TPC script. All of the modifications shown here deal only with our animation code. No other parts of the code are disturbed.