A character animation toolkit written in C++ and compiled into a native Unity plugin. It plays motion capture on a jointed skeleton, poses that skeleton with inverse kinematics, and uses both to make a character walk toward a target across uneven ground.
Each joint stores a transform relative to its parent. Walking the hierarchy from the root gives every joint its place in the world:
\[ T^{\text{global}}_{j} = T^{\text{global}}_{\text{parent}(j)} \; T^{\text{local}}_{j} \]
Each frame samples the clip’s rotation splines for all joints and its translation spline for the root, then updates the hierarchy.
IK works backward: given where a hand or foot should go, find the joint rotations that put it there. There are three solvers, which suit different chains.
Limb IK (analytic). For a three-joint limb with bone lengths \(l_1, l_2\) and a target at distance \(r_d\) from the upper joint, the law of cosines gives the middle joint’s bend. The upper joint then rotates to aim the limb at the target.
\[ \theta_2 = \pi - \arccos\!\left(\frac{l_1^2 + l_2^2 - r_d^2}{2\,l_1 l_2}\right) \]
CCD (iterative). Works along the chain from the end joint inward. Each joint \(j\) rotates to bring the end effector closer to the target, with its share set by a per-joint weight \(w_j\). Here \(\mathbf{r}_{jn}\) points from the joint to the end effector and \(\mathbf{r}_{jd}\) from the joint to the target.
\[ \theta_j = w_j \arccos\!\left(\frac{\mathbf{r}_{jn} \cdot \mathbf{r}_{jd}}{\|\mathbf{r}_{jn}\|\,\|\mathbf{r}_{jd}\|}\right) \]
\[ \mathbf{a}_j = \frac{\mathbf{r}_{jn} \times \mathbf{r}_{jd}}{\|\mathbf{r}_{jn} \times \mathbf{r}_{jd}\|} \]
Pseudo-inverse (Jacobian). Builds a Jacobian \(J\) relating joint rotations to end effector motion, then solves for the smallest joint change that reduces the error \(\mathbf{e}\). Each step is limited to 0.1 radians per axis, which keeps the pose stable.
\[ \Delta\boldsymbol{\theta} = J^{T}\left(J J^{T}\right)^{-1}\mathbf{e} \]
Guide joint. A walk clip returns to its starting point when it loops. A virtual joint above the hips fixes this: before each cycle it moves to the character’s position on the ground and turns toward the target, so the next cycle continues from there.
Foot IK. Each frame, Unity ray casts the terrain’s height and normal under each foot. The hips shift by the lower of the two foot heights, limb IK raises the foot on higher ground by the difference, and each foot rotates to align with the surface normal.
| Tool | Used for |
|---|---|
| C++ | Transforms, skeleton, motion playback, and IK solvers |
| Unity 2022.3 | Native plugin host, terrain ray casts, and the walking scene |
| OpenGL viewer | Testing FK and IK outside Unity |
| BVH | Motion capture data for the Beta character |
| Visual Studio, CMake | Building the toolkit and plugin |
Built on the course’s Animation Toolkit framework, which provides the viewers, the Unity project, and the character assets. Source code is not public, as this is course work.