Vector3.Distance Question

I have this JS line of code to get distance

Dist = Mathf.Floor(Vector3.Distance(pm.target.gameObject.transform.position,_player.transform.position));

I’m getting a distance with this bit of code. But, I am noticing an odd behaviour which is messing up the logic that I am using distance for. The distance amount continues to rise about every 2 passes through the script. For example, the initial distance amount is 6 and after a few passes through the script, it will be 8 and it keeps rising. Nothing is moving.

I have the player’s coordinates printed to the screen and I don’t see any movement there. Also, I don’t see any movement on the target object.

Any ideas of why this is happening or where else I could look. I’ve been bashing my head on this one for a few days now. Please note, I have reveresed the order of the two objects being passed.

Thanks for any advice.

Can you post the rest of the code in the Update method?

OK. I have attached the whole script rather than just the function where this is called. It should help see what is going on better.

Thanks for taking a look at it.

263693–9499–$playercombat_622.js (14.1 KB)