Hiho @all,

i have a small problem.

I have a camerascript that works well for me. I modified it, but i forgot from what progger it is.

I want to make, that the camera hit something, i.e. a wall or terrain, that the camera moves near the character. I tryed alot, but everything i got is a total cracy rotation.

Here is the script:

Code:
 void control_Camera()
{
	
	if(Hero != 0){wait(1);}
	
	camera.x = Hero->x ;
	camera.y = Hero->y ;
	
	

	while(1)
	{
		if((mouse_right == 1) && (HeroMoves == 0))
		{
		vec_set(V_tempDistance.x, camera.x);
		V_tempDistance.z -= 100;
		v_DistanceTraced = c_trace(Hero->x, V_tempDistance.x, IGNORE_ME | IGNORE_PASSABLE);
		
	
		
			
		camera.z += cam_speed[1] * mouse_force.y * time_step;
		//camera.z = clamp(camera.z, 10, 800);
		
	
		cam_angle += cam_speed[0] * mouse_force.x * time_step;
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		
		if(v_DistanceTraced >0)
		{
			v_DistanceTraced -= 2;
			camera.x = Hero->x  - v_DistanceTraced * sin(cam_angle);
			camera.y = Hero->y  - v_DistanceTraced * cos(cam_angle);
				vec_to_angle(camera.pan,V_CamVecTemp);
		}
		else
		{
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		}
		
		}
			
			
			
		if((mouse_right == 1) && (HeroMoves == 1))
		{
		camera.z += cam_speed[1] * mouse_force.y * time_step;
		//camera.z = clamp(camera.z, 10, 800);
		
		cam_angle += cam_speed[0] * mouse_force.x * time_step;
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		
		Hero.pan = camera.pan;
		}
		
		
		
		if((mouse_right == 0) && (HeroMoves == 0))
		{
	
		//camera.z = clamp(camera.z, 10, 800);
		
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		}
		
		
		if((mouse_right == 0) && (HeroMoves == 1))
		{
		
	//	camera.z = clamp(camera.z, 10, 800);
		
		cam_angle = ang(cam_angle);
		
		camera.x = Hero->x + cam_radius * sin(cam_angle);
		camera.y = Hero->y + cam_radius * cos(cam_angle);
		
		vec_set(V_CamVecTemp.x,Hero->x);
		vec_sub(V_CamVecTemp.x,camera.x);
		vec_to_angle(camera.pan,V_CamVecTemp);
		}
	
	
	wait(1);
	}

}


I hope someone can help me, please.

Schmerzmittel


EDIT: One point, that i doesnt know to script is the follow: The camera.z should always at the Hero.z but the camera should not move more than 800 quant above the player and not more than 10 quants below the player. How can i do it? I dont figure it out.

Last edited by Schmerzmittel; 01/14/09 19:01.

A7 Com V7.80