I did something like this with an experiment a long time ago.
Here is some of my old code. I am no longer using it. I just deduct stamina based on time now once movement starts, but anyway, here's my old code. Maybe you can use it to figure out what you need.
Note that this code may not be optimized. It is very old. It's just the only thing I had that used distance traveled. So, ignore any "mistakes" or whatnot with the overall code. I did this when I was still learning.
I am using "distance traveled" as an instance variable that I created on my character manually. The variable is set by the code you see from the "every tick" event near the bottom. The "thiefbox" is what does the actual pathfinding. You could give it the instance variable as well. Like I said, this was just an experiment I did a long time ago, so the code can be modified however you want. I don't even use it anymore.