I remember coding something similar, I used a ray trace to find points for the next steps and then very simplified IK for single jointed limbs