IK has been used by our hand naturally, eg. when we want to grab a cup of coffee laying on the table that is close to us, we naturally bend our arm just right so that we can accurately reach the cup. IK has been in use in robotics for a long time now.
You might have wondered how most of the games accurately manage to achieve accurate foot placement for their character on not so smooth ground. We know that grounds in games are never a smooth plane just like in the real world where we see pits and bumps everywhere. So how do other games we see manage to properly align their character on bumpy roads despite having static animation? Well, you guessed it, it's "Inverse Kinematic" IK in short. IK has been used by our hand naturally, eg. when we want to grab a cup of coffee laying on the table that is close to us, we naturally bend our arm just right so that we can accurately reach the cup. IK has been in use in robotics for a long time now. So how can we use it? It is pretty easy to achieve in Unity since all the calculation for IK is already done there. I will just guide you on how to achieve that goal using Unity. It's easy.
Initial Setup 1) We need a character whose rig is set to humanoid.
2) Set IK Pass to True in animator component
What do we want?
We need a ground position for our character foot to be placed. This is the position where the foot will try to reach.
We need to calculate rotation according to slope normal so that we can properly rotate our characters' feet to properly align with the surface.
Let's see how we can implement all these with the following code:
Following the steps above will help you set up proper Foot placement in unity. If you want to know more about Inverse Kinematic you can check out official docs.