i want try to find out wich entity is the closest to the mouse_pos3d
i use a trace from mouse_pos3d like this
Code:
vec_add(vec_scale(vec_set(trace_target, mouse_dir3d), 1000), mouse_pos3d);
c_trace (mouse_pos3d,trace_target,SCAN_TEXTURE | USE_POLYGON | IGNORE_FLAG2);
vec_set(mouse_hit.x,hit.x);



and calculate the the dist

Code:
for(i=1;i<=ent_count; i++)
{	
var distance=vec_dist(ent.x[i],mouse_hit.x);
}



with this i have the distance of all counted entitys
but how can i calculate wich is the closest?