to the OP actually there is no need to use magnets, it looks like you are using bend at 90 Digrees and side-side to swin the leg over to the side, that will always cause problems(even in a real human it is probably impossible to do) just use side-side and the leg will bend better, if you want you can use twist on the thigh to point the knee down more or less as well as you show there.