In games like Mario Galaxy, whenever there is an obstacle such as a wall in between the player and the camera, the player's shadow or outline shows on the obstacle so that we can still tell exactly where we are and what we're doing. I'm guessing the code to do so would be fairly simple, but I just can't figure it out.

Here is my existing camera code. The commented part is my failed attempt to achieve some sort of transparency on the wall when it comes between the player and the camera.

Code:
function camera_follow(ENTITY* ent)
{
	while(1) 
	{		
		vec_set(camera.x,vector(-400,0,100));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down 
//		c_trace(camera.x, ent.x, IGNORE_ME | IGNORE_PASSENTS);
//		while (you != ent)
//		{
//			set(your, TRANSLUCENT);
//			your.alpha = 60;
//		}		
		wait(1);
	}
}



My second problem is that even when the player's pan angle changes just slightly, the camera follows. It's always perfectly behind the player. I want it to only start to follow if the player has turned more than 30 degrees to the left or right so that we get to see the player's side view sometimes and not just always his back view. To test my camera code, add this line to your player code:

Code:
camera_follow(me);


Last edited by tolu619; 05/02/14 10:49. Reason: updated code