
Procedural Animation

FABRIK
The final version of this project uses FABRIK (Forwards and backwards reaching inverse kinematics). A technique used to calculate how much each joint need to bend in order to reach from one point to another. This is an itterative algorithm that reaches back and forwards until a solution has been reached (see video below).


A massivly slowed down visual example of how FABRIK works.
I initially used the law of cosines to calculate the angle a joint would need to bend, but decided to change to FABRIK as it is a lot easier to implement when using an unknown number of joints, this method works for any number of joints without any tweaking.
Foot placement
Each leg has a prefered position for that legs foot. This is the resting position of the robot. When the distance from where to foot is to where it wants to be is too great, that leg will take a step, granted that all other conditions are met for a step. The other conditions includes for example that not too many legs are already stepping, and also that it has a valid position to step to.
In order to calculate the prefered position a raycast is shot down from an offset off the body. If it hits solid ground, it reads the position and normal of the hit and that becomes the prefered position for the foot.
If it doesn't hit a valid point, if it for example is walking over a gap, it should try to find the nearest valid point. The way it finds this is by checking outwards in a spiral from the first offset until a valid point is found.



By checking in a spiral with equal spacing of each new check, we make sure to find the nearest valid point without too many unessecary checks, as the raycasts can become expensive. The offset points in the spiral are not calculated each time, but are cached at the start, however the raycast still needs to be checked every frame.
Leg based speed constraints
The movement speed of the robot is constrained to how fast it can physically move its legs. This is to prevent the body from floating away with its legs lagging behind.

Without this constraint, you would have to tweak the movement speed of the body against the speed at which legs can move. In this example the body is moving faster than the legs can keep up.


With this constraint we only need to tweak the speed that a leg steps and the body is forced to follow the speed at which the legs can walk. This makes it a lot easier to play around with values