It took a lot of work, but the rig for the Robot is done. This was without doubt the most complex rig I have ever made (including the different objects made for my Mastering Driver in Blender video course). It consists of 167 individual bones, and an addon that manipulates it which was needed to solve a very specific problem.
After a bunch of experimenting, I pretty early on realized that I will not be able to construct a "normal" working IK-rig for the feet. This is when you can put a foot in certain location and have it stay there, even when you move the rest of the character. Therefore, I have decided to animate the entire thing without it, only using what is called FK, where moving one bone moves all other bones connected to it as well (I go into more detail about this in the video that demonstrates the rig down below).
I try to see it from the positive side; this will make it look even more like a robot since it will rotate joint by joint in a much more isolated manner than what an IK provides (which allows you to move a hand from point A to point B in a straight line). However, I still need a way to plant the feet in a single location for it to be able to walk, and this is where the problem came. I simply couldn't get this done using the normal Blender tools, like constraints and drivers, so I decided to write a python script/addon to make it work.
Since this was such a complex matter, I slowly went step by step, only starting with a few bones and making sure it worked for that smaller rig and fewer functions, until I moved on making it more complex. Above is the (beautiful) test rig I created to make sure everything worked script-wise, before I attempted to adapt it for my Robot.
Even with the test rig working exactly like I wanted it to, it ended up being fairly difficult to adapt the Robot so it worked like intended. A lot of tests, troubleshooting and adjustments, I finally got it to work like I wanted it to. Here is a video that demonstrates the finished rig, and talks a bit about how it works:
If you like the project, please consider following it!
The script that does the "magic is actually very poorly optimized due to my lack of understanding in how Blender updates and references data, meaning I am repeating calculations as a brute forced way to make sure everything update correctly. However, these calculations are only done when I click the button "Set Root", which I will only do a handful of times while animating. This generates keyframes as a way to store the result. This means the code is not activate at any other point in time (like affecting the playback), so I did not want to any spend more time reducing the execution time.
The code that is actually run each frame update has been fairly optimized, since that one will actually affect my ability to work (I want the best possible playback speed of my animations). I only do things when a switch happens (setting object visibilities), leaving most of the playback basically unaffected.
Another problem with the script is that you can't switch from left foot to the right foot right away. Instead, you first have to switch to the torso as root, and then to the other foot. This means two clicks extra, on an event which will only happen a few times during the entire film production phase. With the same reasoning as above, I felt like it was wise to leave it as is since it would take a lot more time on my part to try to get it to work than the extra clicks will.
It was hard, but this rig is actually completely without dependency cycles, making it run smoothly. I could not solve the "muscles" perfectly without cycles using constraints, so I did an approximation using drivers. The parts drift a bit since it is only a simple approximation, but I think it will work well. I do think the benefits of having a conflict-free rig when animating outweighs the minor loss in quality.
Be sure to try (and inspect) the rig by downloading the finished .blend-file down below!
So, this completes the work on the Robot for the moment. Now I will move on to model more of the objects needed in the film, more specifically some of the smaller items. See you later!