Main character has been modeled and rigged, now it’s time to animate it. This is quite big topic even if we’re talking just about one character, so I decided to split it into 3 parts. The first blog-post is dedicated to the basics character animations that created in 3D modeling software like Blender and then imported to the game engine.
The second part will be about procedural animations, which completely or partially created and controlled in game engine using code. In the third part I’m going to add different attack animations and also try to assemble everything together to see how the whole flow works.
Preparation
As with the rigging, I didn’t have previous experience in character animation, so I decided to spend some time and research the topic.
I chose 2 books that were recommended by my friends and colleagues and I also read a lot of good reviews about them in Internet:
The first book “The Animator’s Survival Kit” is about fundamental principles of classic animation and considered one of the 2 best book about this topic alongside with “Illusion of Life” from Disney’s animators.
The second book “Game Anim” written by former Naughty Dog animator explains animation more in context of modern tech and video games in particular. Also author expands 12 fundamental principles of animation and adds 5 more principles that related specifically to video games animations.
Having all this basic knowledge I started to apply it in practice.
Basic character animations
In platformer games the main character most of time runs, jumps or waits for player’s input. So, we have 3 basic and the most important animations:
- idle (doing nothing, waiting for the player)
- run
- jump
These animations player will be seeing most of the time, so it important to have them done right. They could be not very spectacular, but at least they should fit properly and should not be irritating or frustrating. Otherwise player will have bad experience and we certainly don’t want it.
Idle animation
As Jonathan Cooper said in his book:
There’s nothing more of a wasted opportunity than lazy bouncing or breathing idle.
But how to make the idle less boring, more alive and dynamic? I tried several options and the most interesting one in my opinion is wind. It allows to have a lot of secondary motions: cloth and scarf flapping, hair and feather movement, etc. Because all of them move with different frequency it also helps to break repetitiveness. Also this heavy breathing and visual tiredness of the character might help to convey the mood.
Run animation
The idea was to make it a bit loose and exaggerated. Kinda zombie-style run to show contrast between Corrupted Prince and normal Prince which is strong and stiff. Also I believe this way it will be more visible and readable when character will be small on the screen.
When I published this gif for the first time in my social networks I got feedback that arm with the sword stretched unnaturally. The initial idea was to show the wight of the sword, but it seems I did it too much so I tweaked the animation (you can see it on following gifs).
Jump animation
For the jump I made 3 looped animations:
- flying up
- hovering
- falling down
Inside Unity I created Animation Blend-Tree and set up smooth transition between these animations depends on vertical speed of the character:
Additive animations
Let’s take a look at these 3 main animations in game…
It’s seems ok, but there is something missing…
Inertia. Inertia that would give sense of mass to the character’s body. In this case we can add inertia at run start, run stop and landing after jump.
When we start running, we first bend and lean forward, so our body starts falling and gravity helps us to accelerate. When we stop abruptly our torso keeps moving forward and it takes some time to stop it and bring back to the neutral position. When we land after jump we bend our knees to reduce the impact.
We could create complete animation for each case (some AAA games are doing so), but what if we have several run animations? Making 3 extra animations for each run type will significantly increase the scope.
In this case we can use additive animations to solve this issue. The main difference here is that we don’t need to animate the whole character but only those parts that will be moving depends on certain conditions (e.g. leaning forward when start running). After that we create new Animation Layer inside our Animator Controller, make it additive and play these extra animations here:
Using this approach we can play these additive animations when transitioning from any idle to any run animation or from any jump to any idle, etc. This is how it looks in my case:
Moving on slopes and curvy surfaces
Depends on the game you’re making you might need to implement moving not only on a flat ground but also on slopes. For my game I decided that I need character to be able to move on slopes, curvy surfaces and spinning objects when slope angle changes in real-time.
There are several techniques to achieve this result.
First, I decided to test how my custom skeleton works with IK. I used FinalIK plug-in and its component Grounder for the foot-placement. First test on oscillating cube was quite successful.
It looks good enough when the slope is not very steep, but when it gets closer to 45 degree (maximum allowed slope angle to walk without sliding down) there are problems:
- bottom leg stretching to much
- feet rotating unnaturally
- it’s quite noticeable that torso is not moving and there is no weight shift
- the sword clipping through the ground
Same problems appeared for run animation:
To solve these issues I made 2 more animations: run uphill and run downhill. Then I added them to Animation Blend-Tree and started mixing them depends on the current slope angle. This is what I got:
I used same approach for idle animation:
This is how Blend-Tree looks like:
First fork controls blending between idle and run animations depends on horizontal speed of the character. Second fork blends animations depends on slope angle.
BTW, additive animations work perfectly with all these new animations, no extra work needed.
Bonus: Double jump
The main character’s abilities suppose to have procedural animations that I’m going to talk about in the next blog-post. But there is one ability that doesn’t require procedural animation and it is Double jump using Bat wings.
This is original concept art for this ability:
This animation at 50% speed:
And this is how it looks in game:
What’s next?
In the next DevLog I plan to talk about procedural animations of the main character:
- Moving on walls and ceiling using Spider Legs that will be procedurally placed on the arbitrary surface.
- Using tentacle as grappling hook: procedurally create and animate the whole tentacle mesh.
- Snake tail animation while moving inside curvy tunnels during dash ability.
To support project please add King, Witch and Dragon to your Steam Wishlist. To get more updates and materials about the project follow me on Twitter and Instagram.