well, it appears I have solved the problem on my own. I re-wrote the lines with vec_set(camera.x,player.x), to read
camera.x = player.x; camera.y = player.y; camera.z = player.z+35; and removed the vec_set(camera.pan,player.pan).
it works perfectly now. this is the final working code,

camera.x = player.x+3;
camera.y = player.y;
camera.z = player.z+40;

player.pan -= 5 * mouse_force.x * time_step;
player.tilt += 3 * mouse_force.y * time_step;

player.tilt = clamp(player.tilt,-20,40);

camera.pan = player.pan;
camera.tilt = player.tilt;