you dont need c_trace.
only vec_dist will be good enough.
vec_dist returns the distance between 2 vectors.
c_trace creates a line between 2 points, and checks for collision along the way.
if it hit's anything, it will return the distance from the position it traces to the point it hits something.
hope I made some sence there.
regards,
EDIT: after looking more closely at your code, there are several issues.
Dont load a .hmp file, create a wmb with WED that you load.
also, here is the script fixes I made in your code.
now it should work:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>
////////////////////////////////////////////
var distance = 0;//ok
ENTITY* ball1;
ENTITY* ball2;
PANEL* first_pan =
{
digits (30, 30, 2, *, 1, distance);
flags = VISIBLE;
}
function main()
{
level_load("small.wmb");
wait(5);
ball1 = ent_create("earth.mdl", vector(0, 0, 30), NULL);
ball2 = ent_create("testball.mdl", vector(0, 0, 65), NULL);
distance = vec_dist(ball1.x, ball2.x);
}
If you want to constantly update the distance, put the vec_dist calculation in a loop in your main function.