Foot IK and Ramps

Every once in a while I get a question about why a character’s foot is floating while they are on a ramp. Even with a solution like the Bone Controller and its Foot IK Motor, it still happens.

It looks something like this…

You probably noticed that this is Assassin’s Creed Origins and not my Motion Controller or Bone Controller, but the effect is the same. The problem really comes down to games not being able to truly simulate the physics of the human body and the real world.

 

The Root of the Problem

In the real world when you stand on a steep slope, your center of mass lowers until you have balance with your left and right legs. These two contact points and the resistance from your legs determine the height of your hips and center of mass.

In games, we can’t do those kind of real life computations and stay at a playable frame-rate… So, we cheat.

In most cases, we use a capsule collider or a single root. The Motion Controller uses a single root that’s typically at the center of the character. I talk about this in the Actor Controller User’s Guide.

This approach works really well in most cases, but ramps can cause an issue. That’s because while the root is sitting on the ground it’s possible that one of the legs can’t reach.

You can see this in Assassin’s Creed Origin and you can see this in my Motion Controller.

In the picture above, you can see that the left foot collides with the ground. However, the right foot doesn’t even reach the the ground. It makes sense when you think about the root being the grounding point.

Unfortunately, even foot IK doesn’t help the right leg. If the right foot doesn’t contact the ground, there’s no need to bend the knee. We also can’t stretch the leg to reach the ground as that would look ridiculous.

 

What About Capsule Colliders?

Some character controllers use capsule colliders instead of the root. Unfortunately, this is even worse. If you think about the collision that happens, you’d end up with something like this.

This ends up being worse as the capsule can hit the ramp before the root does. It also makes handling stairs harder.

 

Solutions

There are two options that I can think of:

First, you could implement a multi-contact point character controller that really does use foot placement and leg resistance. With this approach, you could mirror reality, this option isn’t something the MC supports.

Second, we could create some ‘sink’ that actually forces the character down when he’s on a ramp.

I think the second approach is more feasible, but it really has to do with how you setup your character. In the picture above, you can see that I have an intermediate GameObject called “Sink”. Without any code, we can simply drop the position and you can see that the left and right feet touch the ground. Foot IK will kick in for both.

Unfortunately, when you’re on flat ground this looks horrible as your character is always squatting. That leads us to some kind of code that would slowly sink and raise the intermediate GameObject as the character moves around the level.

Creating a ‘sink’ would work, but you’d have to deal with all the edge cases that comes with a “fix” like this. If you watch AC: Origins, they try to do some fixing, but only after the character stops moving. Even then, it’s weak.

This second option is more doable, but it’s not something the AC, MC, or BC do by default. It’s something you’d have to code for.

 

Summary

At this time, I’ve chosen not to implement the sink as an “official” solution because I’m worried about all those edge case.

The truth is that this is one of those things that even AAA games haven’t solved. I figure if AC: Origins and their $200M budget can’t find a great solution, it’s probably something we can live with too. 🙂

 

Leave a Reply