Ok, now we've got a second code snippet that writes values into your distance vector. The most important thing is still missing, namely the part where the actor is moved according to dist.z. It's also important how your first code fragment is called. In order to help you we need a more complete view of the problem.

Imagine you're assembling a clock and you've come to a problem there. Now you're asking in a forum for help and show two photos of two small gears. That is not enough. The other members need to understand how the different gears of your clock come together and interact. ;-)


Always learn from history, to be sure you make the same mistakes again...