About a year ago I thought it would be cool to create giant monsters that the player could climb up. The previous article talked about the climbing mechanics initial robot/IK algorithms that are required to drive the giant monsters. Since then I’ve prototyped several monster “types” and picked three that worked well. They are:
- A quadruped (turtle)
- An inchworm/snake
- A blob/ooze
Let’s look at each and see how they’re put together.
The Quadruped (Currently A Turtle)
The turtle is set up as a giant robot with four limbs. Each limb is made up of several physics bodies connected by joints, like the monster in the previous post. The main body is a single large chunk, and limbs are attached to the main body and each other with hinge (2 DOF or 3 DOF) joints.
Legs are moved using inverse kinematics coded up in the previous post. The feet are basically the end affectors. This allows me to swap in different meshes for the leg segments and modify the bend limits of the various joints. All four feet are controlled at once, using the central body as the IK base.
Quadrupeds have several styles of walking usually called “gaits”. After trying several different gaits I settled on the trot, a gait where diagonally opposing limbs move at the same time. It works well enough for now, where “well enough” means that the turtle doesn’t fall over.
The Snakey Thing
This monster was supposed to be a snake but ended up working more like an inchworm. This is because actual snakes rely in part on anisotropic friction, where friction between the snake and ground varies with direction. The underside of the snake can slide forward along the ground easily but does not slide backwards or sideways very easily. This combined with the snake’s wave-like motion (which I’ll call undulation) causes it to move forward or sideways.
Unfortunately since UE4 uses PhysX as its underlying physics simulation and PhysX discontinued anisotropic friction a while ago. Thus in order for the snake to move it has to use an up/down motion more similar to an inchworm or caterpillar than an actuall snake.
The undulation motion is controlled by several parameters like amplitude, frequency, and phase. These parameters aren’t tuned by hand because that would take forever and would need to be re-tuned every time the snake geometry is modified. Instead I use a variation of the Nelder-Mead algorithm to figure out a set of parameters that will maximize the snake’s forward movement. The algorithm can be re-run additional times to make the snake move backwards, sideways, or turn.
The Giant Ooze
I tried to get the Ooze to work as a round blob thing, but it was not very stable. The best I could do was to make a flat “carpet” that flopped and flowed around the ground and over obstacles. The ooze itself it really just a bunch of sphere-like meshes lashes together with hinges and spring joints. The spheres are laid out in a hexagonal pattern, which looks a little more organic that laying out spheres in a square grid.
Each sphere in this “carpet” has a second sphere attached underneath it that I’ll call a “roller”. The roller overlaps the original sphere without collidiing and is attached to it with a hinge joint. When the ooze has to move the main spheres stay upright and the roller sphere rotate so that they push along the ground or whatever else is under the ooze. This gives the appearance of the ooze flowing although there is actually no sliding or flowing action involved.
There they are, three giant monster things built using physics rigid bodies and joints. All are climbable and interact with their environemtn as you’d expect. Next up is making some better meshes and textures, then adding basic navigation so the monsters can wander around the landscape. Hopefully that won’t take another year! (sigh)