How to keep foot planted on ground when making walks?

Hello, I am trying to rig characters to make a basic game but when i make walking animations i cannot keep the foot from going underground without having to move it for every frame, is there a way i can rig it in a different way that can fix this? this is a picture of the rig i have made.
I want to keep the foot from going underground when i try to animate (I haven’t animated this character yet in case there is another way to rig this.


You need to learn IK constraints. Type that into a youtube search and you’ll find tons of info.

What you’re looking for is a basic “reverse foot” rig. I learned to build one from Blender Foundations. There are also a bunch of videos online. Use either “reverse foot” or “IK constraints” as Daren suggested.