Hey MadMark!
Now the new changed code for you (and all other people):
function Cam1()
{
var cam_goal_dist = -40; //Variable for the camera-distance
//camera.z = Ships[1].z + 850; //thats the cam-starting position
camera.x = Ships[1].x; //the x and y position is always the player x and y position
camera.y = Ships[1].y;
camera.z = Ships[1].z;
while(1){
rotate_rel(camera.x, Ships[1].x, Ships[1].pan, vector(cam_goal_dist,0,0));
if(key_u != 0) { cam_goal_dist += 2*time_step; }
if(key_i != 0) { cam_goal_dist -= 2*time_step; }
//camera.x = Ships[1].x; //the x and y position is always the player x and y position
//camera.y = Ships[1].y;
/*
cam_goal_dist = Ships[1].z + 850 + facCamAbst; // always the standard-distanze plus the variable distance
// how the variable-distance ist calculated you see in Pl_Ship.c
if(camera.z < cam_goal_dist) { camera.z += 1.8; } // the cam position follow the calculated cam_goal_dist variable
if(camera.z > cam_goal_dist) { camera.z -= 1.2; } // the reason why i use this: it brings more "dynamic" to the cam-movement
*/
camera.tilt= 0;
camera.roll= 0;
camera.pan = Ships[1].pan;
wait(1);
}
}
and the same code again, but this time without "nonsense":
function Cam1()
{
var cam_goal_dist = -40; //Variable for the camera-distance
camera.x = Ships[1].x; //the x and y position is always the player x and y position
camera.y = Ships[1].y;
camera.z = Ships[1].z;
while(1){
rotate_rel(camera.x, Ships[1].x, Ships[1].pan, vector(cam_goal_dist,0,0));
if(key_u != 0) { cam_goal_dist += 2*time_step; }
if(key_i != 0) { cam_goal_dist -= 2*time_step; }
camera.tilt= 0;
camera.roll= 0;
camera.pan = Ships[1].pan;
wait(1);
}
}
With the key " U " and " I " you can scroll / change the distance between camera and spaceship.
scroll down to "zero" and you have your 1person camera. or change the value "cam_goal_dist" to zero.
The important part is this function:
rotate_rel(camera.x, Ships[1].x, Ships[1].pan, vector(cam_goal_dist,0,0));
have a look at "F_math.c". there you see how ot calculates the position for the camera.
I hope it helps you.
But remember, thats simply the code for 2.5D. you cannot fly in complete 3d.