Hello,
I am confused with a situation i encountered.
First take a look at the 3rd person camera code...

Code:
function handle_camera() {
	var temp;
	var cam_center=55;
	var camera_distance=150;

	camera.pan -= mouse_force.x * 12 * time_step;
	camera.tilt += mouse_force.y * 8 * time_step;
	camera.tilt = clamp(camera.tilt,-45,45);
	temp = fcos(camera.tilt,-camera_distance);
	vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + cam_center + fsin(camera.tilt,-camera_distance)));
	VECTOR temp;
	vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
	vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
	vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
	
	result = c_trace(vector(my.x,my.y,my.z+cam_center),temp.x,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS); //trace from the player to 16 quants behind the camera.
	if (result > 0) {
		vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
		vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
		vec_set(camera.x,target.x); //place the camera at the trace hit point
		vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
	}
}



The camera is standing behind the player and it is tracing 16 quants behind camera for obstacles and gets closer to player as the camera colides with obstacles.

Let's say camera colides with the wall and the c_trace returns result 140. Now as the camera gets closer to the wall the result keep decreasing.
Now what i want is as the result keeps decreasing i want to keep the camera.z increasing and vice versa.
Ihope you understand what i mean.
Thanx