In game prototyping there are always many ideas that come up and it’s always hard to decide how much time to spend on each prototype. You don’t want to spend too much time on them as they are only prototypes but you also want to spend enough time on the prototype that you can prove it out and highlight problems.
One game I worked on wanted to have a robotic walker with 3 or 4 legs moving over complicated geometry. It was tall and had long legs that it would use to step over obstacles.
It ended up becoming the Sectopod in The Bureau.
To solve the movement of the walker I made it so that the collision of the walker was floating over the ground and I did raycasts against the ground to find the height that it needed to hover. I used interpolation on the position to smoothen out the correction in height. Because the collision was floating up in the air the walker could easily walk over small obstacles. I also didn’t want to use an average position but it was important that the closest distance to ground was used, with a slight factor towards the average. This would ensure smooth reactions to small bumps.
Moving the walker over obstacles is one thing, making that look good is another thing. Generally in realtime applications you will want to use an IK solution on top of animations to correct the placement of the feet to make the animation look grounded, this is a relatively easy and well used solution and this is what I went with. We had IK joint targets precalculated from the animated pose and I set it up so that we had two bone IK chains for the legs of the walker and then did raycasts at the positions of the feet down and moved the target up or down to align it with the ground.
One of the more complicated problems here was handling the turning and walking of the walker and making it move its feet naturally (well mechanically). I had an idea which was to create a system that would constantly find the best foot to move towards a target.
This system was set up so that I calculated the optimal positions for the feet every frame and if that optimal position was outside a certain range the feet would reposition to rebalance the walker. There was dynamic weighting calculations and stride calculations so that the walker would always try to choose the best leg to reposition first and it had a fixed limit of being able to move only two legs at the same time.
The foot move was done by doing two raycasts, one at the target position and one at a midpoint position between the target and the current position. That midpoint position was used to move the feet over small obstacles.
Another clever thing we did was to use animation for the upwards and downwards movement of the legs, this way we had a way for the animators to author a nice nonlinear move of the leg. In one of the prototypes the leg was a gripping type so it would grab with a claw on the reach.
This system was a procedural system which doesn’t always generate the best quality result so we had to come up with solutions to make this look better and we did that by using additive animations.
We had blend spaces for leaning down when the balance of the feet was so that the walker was bending down in a direction. We had blend spaces for leaning up for the opposite.
We had layered noise animations on top to simulate it being active, we used a blend space for velocity so that we had more noise when it was moving.