I’ve been trying to create a realistic feel when moving across lumpy terrain with quadrupeds, but have come up against a few problems.
I’m trying to create a movement system which;
1 - Reacts to collisions from other moving characters using physics
2 - Orients correctly to sloping terrain,
3 - Is able to slide on steep or ‘slippery’ terrain
4 - Lowers slightly when first entering an upwards gradient, and raises slightly when exiting one or entering a downwards gradient.
5 - Leans into sharp turns.
After a pile of failed prototypes, my current idea is to treat the moving character as a motorbike. So, basically I set it all up somewhat like a two wheeled car, using wheel colliders and suchlike. Because most animals move with their feet falling in an approximate line, doing it two-wheeled means less feet go dissappearing through the terrain than with four. The other reasons I’ve opted for two is that in order to facilitate the sharp turns the player can make, the wheels on a four wheeler would have to be quite far apart to avoid flipping. This means that when standing close to a cliff you tend to hover weirdly in the air, as the visible character model would have to be narrower than its ‘wheels’. Conveniently enough the use this technique, with some suspension and the inbuilt physics sorts out requirements 1 to 4, but alas not 5.
So now we get to the actual question. The problem with motorbikes is that they not only keep falling over, but they also lean away from a turn unless told to do otherwise. How then can I stop my characters from perpetually falling over, and also script some leaning in the opposite direction to turns?
Oops, forgot to mention that one. Yep I gave it a try, but dropped it for a number of reasons.
Firstly it failed to meet 1 and 3. This could be overcome with enough effort I’m sure, but I also couldn’t get the different gaits to transition smoothly (I’ve been writing my own way of doing it which does them better, but won’t work with the locomotion system). Additionally, when traversing steep terrain you tend to get legs going all over the place.
Also, what I’m creating is essentially a long-term learning project, so I’m trying to do everything I possibly can, from writing shaders to composing and performing the soundtrack, because lets face it, if I just slap on the locomotion system then all I’ll have learnt is how to apply the locomotion system. “Spoon feeding in the long run teaches us nothing but the shape of the spoon”.
Finally, don’t get me wrong, it’s a brilliant piece of kit in many, many ways, and the biped locomotion is better than anything I could ever hope to achieve, but in all honesty, having studied and worked with animals for many years now I have to say the quadruped part of it didn’t feel as good.
Thanks for the reply though, it’s still a perfectly sensible suggestion.
Sounds like what you are looking for are routines that use physics motors to drive the joints in an attempt to match IK animations.
There’s a bit of information on the techniques involved floating around on the interwebs. There exists expensive middleware for the pros, but the only time I’ve ever seen it tried in Unity is the FlashBang folks driving their character in Minotaur China Shop.
The best I’ve seen in the past couple years are folks that use physics based characters, but with a neural net slapped on top. Far beyond my pay grade, but iirc there is source code and a white paper available that goes along with the above video.
Something like in the video would be ideal, and may well be a project for the future so thanks for showing me. Unfortunately I feel it’s a bit beyond me at the moment, but if I start reading up on it now then I could always integrate it subsequently. Still, in the meantime I’m hoping things need not be so complicated.
I’ve slapped together a quick picture to help illustrate things, as I find it hard to talk about axes without some kind of reference point. To elaborate a little, what I’m looking for is basically the Freeze Rotation option for rigidbodies, but only across the local x axis (in this example). For that axis alone I want it to be under scripted control so I can lean it left and right based on the inputs for rotating the character. If a large enough force is detected hitting the wolf from the side then I can enable this theoretically disabled rotation again and dump the whole thing into ragdoll mode. Does that make more sense?