OK ALMOST there, and almost at my poor brains limits...
Now implemented ::
1> Height and Ball-Angle now calculated from single poly of the surface below the Balls z-axis.
2> "Surfaces" recognised are WED blocks, Models, and Terrains. (theoretically but untested prefabs too)
3> Collision detection added to prevent camera passing through solids.
4> Camera follows Ball, even upside-down. (See NOTEs below)
5> Camera-smoothing added. The smoother the motion, the slower the camera moves. Tweak to preference.

NOTE: This is working well but Im not CERTAIN it is bulletproof. If you ever implement the ball to use its PAN at all,
which I suspect you will, the camera MAY go psycho at 180 degrees of pan. If it does I'll have to rethink 3 or 4 lines
of code. Any changes shouldnt grow much beyond 3 or 4 lines, and should not require any code changes elsewhere.
I'll keep thinking on this issue, but Im out of ideas for now Im afraid.


Give me a performance review please....
Code:
action player_action()
{
	var SetHeight = 20;				//TWEAK :: distance of ball from ground.
	player = my;
	vec_set(my.scale_x,vector(0.5,0.5,0.5));
	wait(1);
	c_setminmax(my);
	VECTOR tmpV;
	while(1)
	{
		if(key_e)	{c_move(my,vector( 5*time_step,0,0),nullvector,GLIDE);}
		if(key_q)	{c_move(my,vector(-5*time_step,0,0),nullvector,GLIDE);}

		vec_set(tmpV, vector(my.x,my.y,my.z-9999));
		vec_rotate(tmpV, my.pan);
		c_trace(my.x, tmpV, IGNORE_ME | USE_BOX);
		if(trace_hit)	// if SOMETHING hit
		{
			vec_to_angle(tmpV, normal);		//get angle of "ground". (Terrain, Entity, or WED block)
			my.tilt   = 90 - tmpV.y;		//apply angle to ball
			if((my.skill1=vec_dist(my.x,target))<SetHeight)
			{	c_move(my,vector(0,0,SetHeight-my.skill1),nullvector,GLIDE);	}
		}
		wait(1);
	}
}



function camera_handling()
{
	VECTOR tmpV, pos_off, ang_off;	//working space
	vec_set(pos_off, vector(-50,0,25));			//TWEAK :: distance of camera from ball.
	vec_set(ang_off, vector(0,15,0));			//TWEAK :: angle of camera, so it looks OVER ball
	var	smoothness = 0.2;						//TWEAK :: smaller is smoother but slower (camera lags behind a bit)
	ENTITY* cam_det = ent_create(0,0,0);	//used for camera-collision-detection only.
	while(1)
	{
		if(player)
		{
			//position camera
			vec_set(tmpV, pos_off);
			vec_rotate(tmpV, player.pan);
			vec_add(tmpV, player.x);
			vec_sub(tmpV, camera.x);
			vec_scale(tmpV, smoothness * time_step);
			c_move(cam_det, NULL, tmpV, IGNORE_YOU|GLIDE);
			vec_set(camera.x, cam_det.x);	
			//rotate camera toward Player
			vec_set(tmpV, player.x); 	vec_sub(tmpV, camera.x);	
  			vec_to_angle(camera.pan, tmpV);
			if(tmpV.x<0)	{  camera.pan -= 180;	camera.tilt = 90-(camera.tilt-90);  }
  			vec_add(camera.pan, ang_off);
		}
		proc_mode = PROC_LATE;
		wait(1);
	}
	ent_remove(cam_det);
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial