Jump to content
  • Advertisement

Matching feet to terrain - Part 2

lawnjelly

1188 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 Nilmani Gautam
      Hello and welcome everyone. I am starting another complete new Tutorial on 3d modelling and animation on blender
      Please comment what types of chapter could i include to make it complete from very beginning to exper
       
    • By GreenGodDiary
      Sup dudes and dudettes!
      I'm in the process of implementing an animation state machine and am currently making a 2D blendspace state for it.
      I think I've figured out how to blend the different clips together given an [x,y] coordinate but I have one problem I'm not sure how to solve; matching the different blended clips' animation speed.

      Say you have your run-o-the-mill twin-stick character locomotion blendspace, where max Y, zero X means running straight forward, and max Y, max X (in either direction) means running at an angle (thus blending run_forward with run_strafe).
      In this case the animations' speed probably match, so there's no worry. However, say I'm halfway up Y, meaning I'm "jogging", in the sense I'm halfway between walk_forward and run_forward, and my X is at some arbitrary point.
      How would I blend these animations together so that their speeds match? Would it be as simple as 'lerping' the animation speed of the walk towards the speed of the run and scaling the speeds of all the clips to match this speed?

      Sorry if the question is poorly written.
       
    • By bilbo92
      Hello guys!

      I want to learn to make my own assets, characters, model and so on for my own games, instead of having to rely on others assets (and be able to create the things I actually want, and not just what I can find that is avalible)
      So I have spend on/off the past month trying to figure out the basic of how it works and such, what to expect and which programs there are avalible and what they cost.
      Truth be told, considering how many different software, tutorials, and complexity of it all, it seems very hard to figure out where to actually start, with this. Especially because it seems as though most of any software that's commonly used when you search the interwebs, it seems as though they are all insanely expensive for a mere mortals. However, I looked at the software called ZBrush because I can see it's a software that is used in big companies like Blizzard, EA and a lot of other big studios, both related and unrelated to the gaming industry like movies and such.
       
      Though it is still a pricy piece of software it is the only software of the big ones that I found that is not a yearly or monthly subscription based software, but a perpetual software license purchase software. A one year autodesk Maya subscription cost more than a perpetual software license from the newest ZBrush version that last forever. In a perfect world were money didn't matter to me, I'd just buy them all and use whatever I liked the best, but I'm not made of gold so I'll have to choose between one or the other of them all. But it just so happens that while I looked up on ArtStation few days ago that I can see there is a 20% of on the newest version of ZBrush until October 1st 11:59 PM which will save me 179$ which is A LOT to me  so I seriously consider to buy ZBrush now that it seems to be the cheapest software of the big ones there is (that I have found so far) and especially now when I have a chance to save A LOT!

      However, as I said before: considering how many different software, tutorials, and complexity of it all, it seems very hard to figure out where to actually start. Even when I look at ArtStation, DeviantArt it seems as though a lot of people even have used both Maya, PS, ZBrush or up to 6-7 programs whereas half of them I havn't even come across or heard of before. So this basicly just make me more confused whenever I think I finally got how it works... So at this point I don't even know anymore, which software does what, which software do I actually NEED, and which software is just "luxury" software (one where they might use 'software A' for this and 'software b' for this, but you can actually do the same in both 'software a' and 'software b', it is just easier to different things in boths software).

      So the question I want to make is truly: If I want to make a character for my game (let's say Sombra Cyberspace from Overwatch), fully animated, complete and all like she is in Overwatch, into my Unity 3D game, which software do I actually use to make all the required steps? How many "steps" are there in the process of doing this? Do I actually need more than Unity and modelling software like Zbrush (If that is what they are called - please correct me if I'm wrong)? Is ZBrush the choice for me or am I just doing a very costly mistake, because it can't actually do what I think it can? Or do I end up having to buy a lot of other different software aswell if I buy ZBrush in contrast to some other software solutions?  Can I actually live without ZBrush or any of all these expensive software solutions?
      When you answer please bare in mind I'm a newb, so please refrain from using very technical answers, or to answer like you think I know something, because I don't. Talk to me as if I'm a total rookie and moron and explain it to me as if I were a 5-year old  
    • By addictCoderCS
      Hi there,

      I'm in need of a dedicated artist who wants to help in the development of a game for switch.
      Stylized/Cartoony style is preferred.

      Requirements:
      Quality 2D Character design
      Ability to create custom weapons and armor + animating them
      Experience with 2D puppet rigging

      Bonus:
      Experience creating 3D environment objects. Exterior and Interior

      Please do not respond if you don't have the time to dedicate to a larger size project.
      If you aren't good with 2D art and animation, but great with 3D environment objects, you can still contact me.


      If you're interested, contact me at addictcodercs@gmail.com
      Please send portfolio. Bonus for animated art. Double bonus for characters switching gear. Triple bonus for animated characters switching gear. 

      Thank you all,
      _addictCoder
    • By null777
      Hello, I'm working on developing a 2D platformer. In the game, the player can run/jump/etc, and they can also often shoot at the same time that they're performing these other actions. For programming these actions, I have no issue constructing the relevant FSMs and getting them to behave as intended. My issue comes when I need to find the right frames or animations for the sprite to show. Should the game just check if the player is shooting and what state they're in and then have the right animations hardcoded in to play in each possible outcome of that if statement? I've considered some potentially more elegant solutions like having a normal sprite sheet and then a shooting sprite sheet where the shooting sheet has the corresponding shooting frame at the same position in the sheet. Then the animator would just have to load the correct frame of its current sheet no matter what, and whenever the player is shooting, it simply swaps out the regular sprite sheet for the shooting one.

      Basically I can think of a few different ideas that sort of solve this problem, but none of them seem ideal. I wanted to know what the generally accepted best practices are for this type of problem. Any advice would be appreciated.
×

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!