Jan 2020
Made with Unity

Based on some brief clips in a Sebastian Lague video, I tried to recreate a procedurally animated spider walk that he showed but did not explain. Of the clips from that video, the one lead I got was the idea of a “foot targeting” system.

Not technically a spider…

Though I couldn’t get quite as smooth results, I ended up with something I was pretty convincing using some inverse kinematics an trigonometry.

The green circles are the places where the spider (or insect if you’d like, since there’s only 6 legs) at complete rest would put its feet. It’s basically the “most comfortable” position. As the spider moves around, it stretches its legs out to try and keep its foot stuck to the ground. When the feet are too far from the green spots, the leg takes a step. The red spots are where the foot originally was, and the orange feet travel an arc from the red (old position) to green (ideal position) circles.

The math was split into two parts to address the two important planes separately. The first plane is the top down view, so I can figure out which way the leg should point. The second plane is the one formed by the two leg segments, which is where I calculate the angles of each leg segment using Law of Cosines.

One of the unfortunate flaws with my version was that each leg moved independently, which could cause them to “sync up” and all the legs would lift up at the same time. But it’s still pretty fun to move the spider around and watch the legs skitter about.