Distance calculation problem

I’m trying to get the distance between two vertices and it is coming back as 1. Whats wrong with my math? Here’s the line of code for the math

distance = Mathf.Pow( Mathf.Pow((vertices<em>.x - vertices[x].x),2) + Mathf.Pow((vertices_.y - vertices[x].y),2) + Mathf.Pow((vertices*.z - vertices[x].z),2),1/2);*_</em>

i= o and x= i+1. Any ideas? Thanks!

1 Answer

1

Well, I’m pretty sure a better way of doing that would be

Vector3 differenceVector = verticies *- verticies[x];*

distance = differenceVector.magnitude;
However, the function exists in the Vector3 class, so why not just use
distance = Vector3.Distance(verticies*, verticies[x]);*

that did it. thanks i was just thinking of subtracting two vectors and forgot the magnitude was already part of the code haha.