Jump to content

Matching feet to terrain - Part 2

lawnjelly

1102 views

crocIK.jpg.8083b5eb906f44b783a1603e38bad2a0.jpg
(This is a follow up to my blog entry here: https://www.gamedev.net/blogs/entry/2264506-matching-feet-to-terrain-using-ik/ )

This is a quick one just to show progress with getting 4 legged creatures matched to the terrain. While it was quite quick to get 2 legged creatures matching their feet to terrain using IK, 4 legged creatures has proved to be a whole other ball game entirely.

The few examples I've seen of 4 legged IK on the web have been using full body iterative solutions, so maybe I should be going this way. However using what I already had working I've so far been staying with the simple analytical solution for the legs, and using some maths and forward kinematics for the rest of the body.

First thing I did was try changing the pitch of the torso. I have been using a rotation based around the pelvis, not sure if this is the best approach but it seems to look rightish. Of course in real life you do not always hit a slope head on, so I wanted to be able to roll the torso too.

As well as this there is a twist in the spine so the body can follow the terrain better. A stiff spine looks very rigid (but is simpler). Then it is a case of lining up the legs to compensate for gravity (this isn't always switched on) and doing the IK legs to the terrain under each foot.

I've had quite a lot of problems with feet not being long enough to reach the ground, particularly with the short legged crocodile. You sometimes have to move the belly up to not hit the ground, but then the legs are too short to hit the ground!

As well as the central body there is also a forward kinematic system for moving the head and the tail.

It has been very difficult making things generic (fixing one thing on the crododile would break the elephant and vice versa) but I am getting there. There are also other creatures which are semi 4 legged (the monkey and chimp) but those are easier for the system to calculate. There are still some bugs of feet going through ground, and glitches, but it doesn't have to be perfect.

 



5 Comments


Recommended Comments

Very nice! How much "setup by artist" does it need? I guess that you are trying to make it as generic as possible to be out of the box? I also want to get down to implement it one day. :)

Share this comment


Link to comment

The elephant seems to have very low traction with the ground, almost as if its walking on ice. Do you have a method to deal with that?

Share this comment


Link to comment

Both the elephant and the croc (but more so the elephant) seem to be sliding a little - the leg movement isn't looking too bad otherwise though! :)

This is tricky stuff to get right, lots of fiddly little adjustments! 

Share this comment


Link to comment

I'm glad you guys were interested, my implementation is very comically bad at the moment :) , but in the game the models are so small on screen I doubt players will notice. If they were relatively bigger I'd spend a lot longer on getting this right, in fact I will probably come back to it, but I feel I've wasted a couple of weeks on tweaking this already!

The sliding isn't actually as bad as in these videos, I should have said, in both cases I had scaled up the models just for the videos so the animation speed doesn't match the movement speed. In the game the match is much better as the animation speed is driven off how far the animals moves, I will try to do a later video soon with all in game.

Also the base animation for the croc is a very bad test anyway, I basically just wiggled the legs in blender! :) Obviously also these are low poly and the skin weightings need some work too, I didn't envisage the joints moving so far when I made the models.

I have seen there is middleware available for doing this with quadrupeds, IKinema and Bik. I suspect they use a better iterative method and I will try this if I have time. But even with iterative I'm sure it took a lot of tweaking to get right. And I am slightly worried it will use more performance as it has to work on mobiles.

I could write much more on how it works (or fails to work lol) if people were interested.

One major change I would make if possible is instead of calculating the solution each frame from the original animation, I would calculate the solution from the previous frame solution, and limit the change in rotations (or even use damping), to prevent physically incorrect snapping. Also as a performance optimization and to further smooth it might be an idea to calculate the solution at a fixed lower tick rate (say 30fps or matching the underlying animation tick rate) and interpolate frames.

Share this comment


Link to comment

Here is example of setup for the most complex animal, crocodile. The others are simpler, especially 2 legged. All this is very hacky and subject to change but should give an idea that setup is not very involved, most is reading bone IDs from a txt file. I'll probably replace it with something much simpler.

num_feet = 4;
// Leg IK chains, end bone, chain length, chain effector, knee joint flip, shoulder joint flip
chain_leg[0].Create(23, 3, 0, true, false);
chain_leg[1].Create(27, 3, 0, true, false);
chain_leg[2].Create(12, 3, 0, false, true);
chain_leg[3].Create(16, 3, 0, false, true);

// Limit knee angles (smallest, largest)
ANGLES_FRONT(0, 104);
ANGLES_BACK(0, 80);

// hips and shoulders, might be inferred from the chains later
SetLegRoots(22, 26, 11, 15);

// chain for back, end bone ID, num bones, effector
chain_back.Create(2, 2, 1);
// chain for tail
chain_tail.Create(19, 3, 0);

// offset in model space from last tail bone joint
m_TailOffset_MS = 6000;
// croc uses an extra 3rd probe for torso orientation
Set_UseMiddleProbe(true);
// neck and 'nose' bone
SetHead(3, 5);

// used for calcing head angles, some of these might be inferred from bones
m_NoseOffset_MS = 4000;
m_NeckNoseDist_WS = 0.2f * Scale;
m_DesiredHeadHeight_WS = 0.1f * Scale;
Set_TiltHeadDown(true); // tilt head down when going down slopes
m_GlobalZOffset_MS = 1500.0f; // overall bodge to the torso height above ground

 

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By Iw/biz
      I'm an animator/programmer, and my specialty is animating static images using 3D modelling software (Blender). Looking for a 2d artist who can produce NSFW images (NOT the sprites/spritesheets, just a static scene) to use in an action-RPG style of h-game. Mostly for a hobby joint-project, but It would be a good opportunity for both parties to practice their skills. Please message if you're interested or want to invite me to an already established team. Thanks!
    • By Effekseer
      Effekseer Project develops "Effekseer," which is visual software for creating open source games; on September 13,
      I released "Effekseer 1.4," which is the latest major version release. 
      Effekseer is a tool to create various visual effects used in games and others.
      With Effekseer, you can easily create various visual effects such as explosion, light emission, and particle simply by specifying different parameters.
      Effekseer's effect creation tool works on Windows and macOS.
      The created visual effects can be viewed on Windows, macOS, Linux, iOS, Android and other environments with DirectX, OpenGL and so on.
      In addition, there are plugins / libraries for game engines such as Unity and UnrealEngine4 to view visual effects.
      Effekseer 1.4 is an updated version of Effekseer 1.3 released in November 2017.
      This update contains the following changes:
      The renewal of UI. Support the tool for macOS. Addition of a function to read FBX with animation. Addition of parameters to protect collied effects and objects. Addition of parameters for easier control of the effects. In addtion I improve plugins/libraries for Unity, UnrealEngine4 and Cocos2d-x.
      Besides that, more than 40 new sample effects have been added and many bugs have been fixed.
      Effekseer 1.4 is available on the project website.
      The license for the software is the MIT license.
      Effekseer 
      http://effekseer.github.io/

      Github
      https://github.com/effekseer/Effekseer
      
      Sample Effects.
      Tool Demo
       

      View full story
    • By Effekseer
      Effekseer Project develops "Effekseer," which is visual software for creating open source games; on September 13,
      I released "Effekseer 1.4," which is the latest major version release. 
      Effekseer is a tool to create various visual effects used in games and others.
      With Effekseer, you can easily create various visual effects such as explosion, light emission, and particle simply by specifying different parameters.
      Effekseer's effect creation tool works on Windows and macOS.
      The created visual effects can be viewed on Windows, macOS, Linux, iOS, Android and other environments with DirectX, OpenGL and so on.
      In addition, there are plugins / libraries for game engines such as Unity and UnrealEngine4 to view visual effects.
      Effekseer 1.4 is an updated version of Effekseer 1.3 released in November 2017.
      This update contains the following changes:
      The renewal of UI. Support the tool for macOS. Addition of a function to read FBX with animation. Addition of parameters to protect collied effects and objects. Addition of parameters for easier control of the effects. In addtion I improve plugins/libraries for Unity, UnrealEngine4 and Cocos2d-x.
      Besides that, more than 40 new sample effects have been added and many bugs have been fixed.
      Effekseer 1.4 is available on the project website.
      The license for the software is the MIT license.
      Effekseer 
      http://effekseer.github.io/

      Github
      https://github.com/effekseer/Effekseer
      
      Sample Effects.
      Tool Demo
       
    • By Madman's Journal
      We are a small team of 2 coders (both with degrees in software engineering) a writer/producer (me) and a sound designer. We are currently looking for a reliable and dependable person to help us with this project. It is in early planning and the art style will be decided by who applies. Think King's Quest style art and game play. Anyone interested please contact me or tell me how to contact you.
      - We are using Unity as our platform and will distribute through Steam.
      - The game will have mature and occult themes, so applicants need to be fine with this.
      - The game requires about a dozen characters and 12 - 24 backgrounds.
      - We are female friendly and welcoming. Creative input is also welcome. You will feel like part of the group.
      Rather than write a wall of text, if you are still interested after reading this feel free to ask questions here and I'll answer them with as much detail as possible. Your questions will also help me learn what information is important to add in the future.
    • By sancyrus
      Hello people.
      Am a Computer science graduate student and planning to do the Game designing course in Canada and this is my personal statement for the college and it is the first draft ,hence no professional or fancy words used here.
      Please help me in the statement before i submit it and let me know if there is anything that has to be cancelled or shortened or edited.
      The essay is way over the specified word limit and i will work on trimming it so please help me on this. Essay attached as txt file.
      Any help would be appreciated.I have just two days left to submit so please reply as soon as possible.
      Thank you. 
      Essay.txt
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!