Help with aligning object to plane

I’ve been trying to find a solution for this but haven’t been able to get anything to work. I’m trying to align my foot to the floor along a plane but nothing has been working. I tried using ProjectOnPlane, LookRotation, Rotate, but none of them worked. Is there any way for me to fix this?

  Quaternion.LookRotation(hitL.normal);
  StartL.Rotate(new Vector3(StartL.rotation.eulerAngles.x + changeAmount, 0, 0), Space.Self);
  Vector3 q = StartL.rotation.eulerAngles;
  StartL.rotation = Quaternion.Euler(q.x, Hip.rotation.eulerAngles.y, 0);

156755-capture.png

Assuming your foot points forward on the z-axis (and you have a raycast hit like in your top example), you can set its rotation via the following ;

Vector3 forward = Vector3.Cross (hit.normal, foot.right).normalized;
foot.rotation = Quaternion.LookRotation (forward);

This works because we know the the hit normal is the desired up axis and our right axis is the same, so to find the desired rotation we just take the cross product of those two, giving us the perpendicular forward axis.