Try something like this:

//Basic player movement
vec_set(temp.x, my.x);
temp.z -= 10000;
temp.z = -c_trace (my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) - 2;
temp.x = 50 * (key_w - key_s) * time_step;
temp.y = 50 * (key_a - key_d) * 0.6 * time_step;
c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE | USE_BOX);

my.pan -= 50 * mouse_force.x * time_step;
camera.pan -= 50 * mouse_force.x * time_step;
camera.tilt += mouse_force.y * 8 * time_step;
camera.tilt = clamp(camera.tilt,-20,40);//30.10
cam_z -= mouse_force.y * 8 * time_step;
cam_z = clamp(cam_z,5,60);//30.10

//cam_z for moving the camera up and down when looking with the mouse
//-106 the distance from the cam to the player
//-16 position the camera on the right side, left side should be 16
//play around with this values
vec_set(temp2,vector(-106,-16,cam_z));
vec_rotate(temp2,vector(camera.pan,10,0));
vec_add(temp2,my.x);
vec_set(camera.x,temp2);


if(c_trace(my.x,camera.x,IGNORE_MODELS | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_ME))
{
vec_set(camera.x,target);
vec_add(camera.x,normal);
}

Edit: I already tested the code and it worked, take a look and tell me if this is what you need.



Last edited by Theil; 01/05/11 20:05.