Procedural Animation

Examples

Game References for 2D Procedural Animations
3D
Top-Down
Platform

Complementary Techniques

Movement transitions

Etc

Inverse Kinematics

IK with Foot Placement
Discussion
Physics Engines
  • Box2D and Jolt Physics are both rigid-body physics engines that simulate dynamic behavior using constraints and impulses. Neither has native support for inverse kinematics (IK), which typically requires solving joint positions/angles to reach a target.

  • However, you can implement IK logic on top of these engines by manually controlling joint angles and positions before feeding them to the simulation, or using constraints in a controlled way.

FABRIK (Forward And Backwards Reaching Inverse Kinematics)

  • How it Works:

    • A two-pass iterative method that moves joints forward and backward to reach the target.

    • Forward pass: Stretches the chain from the root toward the target.

    • Backward pass: Contracts it back from the target to the root.

    • Repeats until the end-effector is close enough.

  • Pros:

    • Fast & simple (no Jacobians or heavy math).

    • Works well with constraints (joint limits, obstacles).

    • Natural-looking motion (good for animation).

  • Cons:

    • Not as precise for orientation control.

    • Can struggle with highly constrained systems.

  • Used in:

    • Games (Unity's IK solvers), animation tools.

  • Visual behavior :

    • Produces smooth, natural arcs (like a human arm reaching).

    • Tends to avoid extreme joint angles.

FABRIK
  • FABRIK demo and implementation .

    • I believe it uses distances, purely approximating one point to another until it is close enough.

      • I'm not certain about this, I haven't watched the entire video.

    • .

    • .

    • .

  • FABRIK demo .

    • It uses vectors, inverting the vector and repositioning it at each step.

  • the-comet/ik .

    • The lib has tons of scripts.

    #include <ik/ik.h>
    
    int main()
    {
        /* Create a solver using the FABRIK algorithm */
        struct ik_solver_t* solver = ik.solver.create(IK_FABRIK);
    
        /* Create a simple 3-bone structure */
        struct ik_node_t* root = solver->node->create(0);
        struct ik_node_t* child1 = solver->node->create_child(1, root);
        struct ik_node_t* child2 = solver->node->create_child(2, child1);
        struct ik_node_t* child3 = solver->node->create_child(3, child2);
    
        /* Set node positions in local space so they form a straight line in the Y direction*/
        child1->position = ik.vec3.vec3(0, 10, 0);
        child2->position = ik.vec3.vec3(0, 10, 0);
        child3->position = ik.vec3.vec3(0, 10, 0);
    
        /* Attach an effector at the end */
        struct ik_effector_t* eff = solver->effector->create();
        solver->effector->attach(eff, child3);
    
        /* set the target position of the effector to be somewhere within range */
        eff->target_position = ik.vec3.vec3(2, -3, 5);
    
        /* We want to calculate rotations as well as positions */
        solver->flags |= IK_ENABLE_TARGET_ROTATIONS;
    
        /* Assign our tree to the solver, rebuild data and calculate solution */
        ik.solver.set_tree(solver, root);
        ik.solver.rebuild_data(solver);
        ik.solver.solve(solver);
    }
    
Chained Constraint
  • Slugs and Fish .

    • Very cool video.

    • I like the strategy used to draw the creature's outline.

  • Slugs and Fish .

    • It does exactly the same thing as the video above, but it is more "cult" / "classical music" / "3blue1brown" and less explanatory.

      • "uuuh parametric equations uhhh 8^P "

    • The method used to draw is the same as the video above, but the style became more GREY.

Two-Joint IK / Two-Bone IK / Triangulation

  • Explanation .

  • Using isosceles triangles .

    • .

  • How it Works:

    • Treats a two-joint chain (like an elbow/knee) as a triangle.

    • Uses the law of cosines to compute angles.

    • Adjusts the middle joint to reach the target.

  • Pros:

    • Blazing fast (perfect for real-time use).

    • Stable & predictable (no iteration needed).

  • Cons:

    • Only works for 2-joint chains (e.g., a knee or elbow).

  • Used in:

    • Game character limbs (Unity’s "Two-Bone IK").

Math

CCD (Cyclic Coordinate Descent)

  • Demo and explanation .

  • How it Works:

    • Iteratively adjusts one joint at a time, starting from the end-effector and moving backward.

    • Each joint rotates to point the end-effector toward the target.

    • Repeats until the end-effector is close enough.

  • Pros :

    • Simple & efficient (no matrix math).

    • Works well for chains with few joints.

  • Cons :

    • Can produce unnatural twisting (since it solves joints one by one).

    • Slower for long chains (many iterations needed).

  • Used in :

    • Early game IK, simple robotic arms.

  • Visual Behavior :

    • Can look "robotic" or mechanical (joints may twist unnaturally).

    • May over-rotate joints in long chains.

  • Comparing to FABRIK :

    • Constraints :

      • FABRIK is better for constrained systems (e.g., human limbs).

      • CCD is harder to limit joint angles (since it works in rotations).  Can break constraints if not carefully tuned.

    • Performance :

      • FABRIK is generally faster, especially for long chains.

      • CCD is slower for long chains (needs more iterations).  Can oscillate near the target (takes time to settle).

    • Implementation :

      • CCD is simpler to code, but FABRIK is more polished.

    • FABRIK is the better choice for most cases (games, animation, robotics).

    • Use CCD if you need a quick and dirty solution.

Soft Body