use this code

Code:
var temp;
var camera_distance = 150;

VECTOR temp3 ;
//////////////////////////////
function handle_camera(ENTITY* ent) 
{

	camera.x = ent.x - 150 * cos(my.pan);
	camera.y = ent.y - 150 * sin(my.pan);
	camera.z = ent.z + 100;
	camera.pan -= mouse_force.x * 10 *time_step;
	camera.tilt += mouse_force.y * 10 *time_step;


	camera.tilt = clamp(camera.tilt, -90, 20);
	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 + 20 + fsin(camera.tilt, -camera_distance)));





	vec_diff(temp3.x, camera.x, ent.x);
	vec_normalize(temp3.x, 10); 
	vec_add(temp3.x, camera.x); 
	result = c_trace(ent.x, temp3.x, IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS); 
	
	if(result > 0) 
	{
		vec_diff(temp3.x, ent.x, target.x); 
		vec_normalize(temp3.x, 16); 
		vec_set(camera.x, target.x); 
		vec_add(camera.x, temp3.x);  
	}


}




Last edited by Dico; 02/05/13 20:53.