Some ideas for how to handle mechs (though you probably already know all this).
At some stage, you want there to be complete abstraction. So you have an instance of a vehicle, and simply say “vehicle.shoot” or “vehicle.move(direction)”. This way you can separate our your AI and keyboard control logic and keep things nice and simple.
This is fine for Tanks, as movement is simple.
But with mechs, walking animations make things hard.
One thing I’ve seen is to use some rather complex weighting. So you set up the legs using inverse kinematics and constrains, and then … work magic. Some of this magic is things like:
- I need to move a foot from behind to in front when moving
- The foot should align to the ground
- Only one foot can move at a time.
- A foot must be roughly infront/behind the torso at all times
If this is implemented correctly, you can get it so that you move the body of the mech, and the legs simply follow suit, walking it along. The position of the mech body is set by the movement. The position of the feet is set by some target empties that move into the right sort of place.
So some example math/pseudocode:
probability_of_moving_foot = all_feet_on_ground * dist_from_center * hip_rotation
foot_position = previous_foot_position or direction_of_mech_movement * rotation_of_mech
So now you have a leg that warps to a correct looking place. How do you get it to draw a nice path from it’s old place to it’s new place? I’m afraid I’m out of ideas for that.
Have I done this myself? Nope
Have I seen it done? Yup, I saw a demo for a six legged vehicle done in a different game engine.
There are a couple videos like these:
These are multipeds, but the same strategy can be applied to bipeds.
Actually, Bipedal walking is not a solved problem (as can be seen by the recent darpa fails). I’m actually interested in procedural bipedal walking to implement in the real world, but I keep hitting mental walls. Thankfully many of these (such as inertia of legs, center of mass) can be ignored in the game world.