GMod / Wiremod / Expression2 – Functional Walking Hexapod.


This is a fully functional walking hexapod for Wiremod!
The whole thing is controlled by a single chip taking in put from 5 Dual Numpad inputs.

Clicky for a vid, download and build instructions!




Each leg uses 4 hydraulics, with 2 turning the hip and 2 raising or extending the legs.
Instead of a hinge mechanic keeping the shin normal to the ground, I had to use a keep upright constraint basically because fewer parts made the thing more reliable, and joints have a tendency to spazz out a bit under heavy loads. It took about 2 days to figure out that certain props respond to keep upright constraints much better than others. For example, a large PHX cube will tend not to rotate at all, whereas the half life props used here will remain upright, but spin on the Z axis quite happily – allowing turning. You might also find that altering the mass of the legs alters this adversely also.
That alone took about 2 days to figure out.

Another issue was the weight. I always wondered how people managed to create massive contraptions that actually managed to stay together when my physics joints were floppy and essentially useless after a certain point. While it does to some extent involve spending rather a long time fine tuning values from clone after clone, the trick here is to download a tool called the Weight STool (yep, there’s a capital T in there).
By making your base heavy, then connected objects lighter, and stuff connected to those even lighter, you’ll instantly notice things staying together a little better. In this case:

Base: 6000kg
Hip : 400kg
Upper Leg: 200kg
Lower Leg: 300kg

With the lower leg being the exception here as 300kg seemed to be the perfect weight to allow the legs to spin freely whilst staying vertical.

The next issue was stuff hitting eachother all the bloody time. It took me a wee while to click on that this wasn’t real life, and if I was ever gonna get this to work, I’d have to accept that certain parts might have to pass through eachother. So each part of the leg was nocollided with every other part of the leg, and each part of the leg was nocollided with the leg opposite and the ones beside it. The upper leg part was also nocollided against the base of the hexapod, so that a single base could be used without a giant hole in the middle for the top. It’s quite unnatural looking, but gets the job done. It also serves the dual purpose of actually making it possible to snap legs back into place when the physics have spazzed hard enough that they’re stuck in awkward positions. Each leg was pre-made (cloned from a single working example) then snapped in place by easywelding the hip directly onto the base – (Yes, the snapping caused it to spazz into place a bit, but ensures that each leg is identical)

I tried to keep the code for this as simple and streamlined as possible, creating an easy framework to access each leg individually, in specific groups, or to create walking/turning/jumping gaits.
If we count the front right leg as 1 clockwise round to 6, Legs 1,3&5 were known as group Alpha, and Legs 2,4,6 were group Beta such that Alpha had 2 on one side and one on the other, and Beta was the opposite.
For both, the AlphaHeight and BetaHeight values -1,0,1 will either Push, Ignore or Raise that group.
We also have AlphaTurn and BetaTurn values, where 1 is forwards, 0 is middle, and -1 is backwards.
(Beta’s hydraulic wiring is reversed so 1 is always forwards, and the middle legs ( 2 & 5 ) are reversed again as they’re on the opposite side).

So when walking Alpha will go Forwards&Up, Forwards&Down, Backwards&Down, Backwards&Up, etc on a loop.
Beta will follow the same sequence, but 2 steps out, so when one set is swinging forwards and up, the other is pushing down and backwards, pushing the bot forwards. 3 legs will always be on the ground.
To reverse, values are simply multiplied by -1. Turning uses a similar sequence synced 2 steps appart.
These values are then passed to the hydraulics and multiplied by some pre-defined constants to provide as much push as necessary.

Initially, to test this monstrosity without days and days of wiring, a single leg on a small rectangular section was built with its own control chip. This was cloned, and 6 were welded together (each base to each other base for stability) and weighted to around 6 tonnes combined. A seventh chip was then used to supply each leg-chip with the inputs for the various sequences. This was fantastic for testing, and I’ve included the advdupe in the .zip file, but due to E2 limitations (sbox_maxwire_expressions) it wasn’t very practical for online play. Still if you fancy making millions of them all joined together, perhaps with articulated sections like an ant, I’d love to see the results.

There are a good few test functions in there just to be fiddled with and demonstrate the code:

7+4 – Forwards and Backwards
9+6 – Turn Left and Right
/+* – Point head up and down (useful for aiming)
+ – Toggle high ride height
– – Toggle low ride height
8 – Hold to raise ride height (even higher) or jump
5 – Hold to lower ride height, or crouch.

The whole thing’s rather large, with a great big base, and strong enough to take quite a bit of weight – E.g. a whole cargo container without much effort. So have a shot at adding weaponry and such. The brain chip too is simple enough that it’s not hard to control it with a second targeting chip which directs the bot towards a target.
i.e. TargetAngle = vec( target:pos() - robot:pos() ):toAngle():z()


Tools used:
Weight STool 1.5 –

This thing took about a week of my life to figure out, build and tweak. If you make an awesome derivative work, the very least you could do would be to give credit where credit’s due – and maybe mail me a wee copy to play with?



 Copy the Expression2 and adv_duplicator folders to:  C:\Program Files\Steam\steamapps\<yourname>\garrysmod\garrysmod\data\
(yes, it has \garrysmod\  twice) 


Leave a Reply

Your email address will not be published. Required fields are marked *