I am studying how to set gravity and I am studying c_trace, but I dont know here:
var dist_to_wall = 0;
var tempZoom = 0;
void plyr()
{
var cam_height;
var cam_angle = 0; // set the initial camera angle here, thiet lap goc quay camera
var zoom = 200;
VECTOR temp;
c_setminmax(me);
set(my,TRANSLUCENT);
my.alpha = 100;
trace_mode=IGNORE_ME|IGNORE_PASSABLE;
result=trace(vector(my.x,my.y,my.z),vector(my.x+100,my.y,my.z));
//result=c_trace(vector(my.x,my.y,my.z),vector(my.x+100,my.y,my.z),IGNORE_ME);
while(1)
{
wait(1);
zoom += 2 * (key_pgup - key_pgdn) * time_step;
dist_to_wall = c_trace(camera.x,my.x,IGNORE_ME);// Khoang cach toi buc tuong, c_trace gui 1 tia tu vi tri nay
//toi vi tri kia và kiem tra tia nay co dung chuong ngai vat tren duong no chieu hay ko
if(dist_to_wall != 0)
{
tempZoom = 10;
}
else
{
tempZoom = 0;
}
cam_height += 3 * (key_cuu - key_cud) * time_step; // thiet lap do cao cua camera
cam_height = clamp(cam_height, 50, 300);
zoom += 2 * (key_pgup - key_pgdn - tempZoom) * time_step;// zoom camera
zoom = clamp(zoom, 20, 500);
my.alpha = zoom;
my.alpha = clamp(my.alpha,10,100);
//camera.x = my.x - zoom * cos(cam_angle);
//camera.y = my.y - zoom * sin(cam_angle);
camera.x = my.x - zoom* cos(cam_angle);
camera.y = my.y - zoom* sin(cam_angle);
camera.z = my.z + cam_height;
cam_angle += 5 * (key_cur - key_cul) * time_step; // 5 gives the camera rotation speed , xoay camara
//temp.x=my.x;// cai nay ko the thay the cho vec_set vi 1 ly do nao do
vec_set(temp.x, my.x);
//temp.x-=camera.x; cai nay ko the thay the cho vec_sub vi 1 ly do nao do
vec_sub(temp.x, camera.x);// temp.x=temp.x - camera.x
vec_to_angle(camera.pan, temp); // rotate the camera towards the player at all times
my.x += key_w - key_s;// di chuyen nhan vat
my.y += key_a - key_d;// di chuyen nhan vat
}
}
void main()
{
fps_max = 60;
video_mode = 6; // 6=640x480 7=800*600 8=1024x768 9=1280x960
video_depth = 16; // 16 bit colour D3D mode
video_switch(0,0,2); // 1 = Full Screen 2 = window
tex_share = 1; // when set to on all entities share their textures saving memory
level_load("test.wmb"); //load the level
}
Ok,Iam calculating distance from player to 100 quants front side the player. Will c_trace return ( >0 :Distance to the hit polygon of the target or of the next obstacle in the way.
=0:No polygon was hit. < 0 A polygon was hit from behind. The from position lies within a solid object, or the me entity intersects with a target entity.)? But when I add watch result in SED, result always is 120

, and When I move box into wall, the value changes but not negative value. Can I help me ?? This full code is here
http://www.mediafire.com/download.php?yggnmqzt3zj