Wrong bone locations while trying to make Leg IK

I’m currently working on leg IK for my game’s main character and I’ve found this problem: when trying to calculate the alpha value for the Leg IK nodes I’ve noticed that my bones locations don’t match with what you see in game. I’ve added a debug node to draw two spheres with different colours for each foot and see what the Get Socket Location node is returning. What I’ve found out is that when the game starts the location is the right one, but when you move and face a direction different than the original one, the location of the bones are wrong.

For example, when you start playing the camera is looking right at your back, so the feet bones locations are shown correctly in their position, but if you move the character and look to the camera the supposed location of each bone is shown in the other foot. Based on this example, if you start with the camera at your back and move forward or left, there is no problem, but if you move back or right everything goes wrong, and the same happens based on the direction the character is facing when you start playing. In this game the character always faces the direction in which he is moving so this seems like a big issue for my current work.

It also seems that these locations of the bones don’t really match their movement, especially when you run, so I want to know if there is better or more accurate way to get my feet bone locations to make a good IK.