erm..., well a little more math is needed than that, but yeah thats nice for a start to learn scripting. It's not psuedo code though, psuedo code is more in a written style:
psuedo code:
Code:
while (player exists) {
set camera [distance] behind player;
wait(1);
}
now for answering the question, this has been asked alot by beginners, and I remember me quite a few times giving an answer. Just perform a search on this forum about "relative rotation".
Anyway, I shall spare you the search this time and give you the answer:
Code:
...
while (player) { //we dont want empty pointers when the player is gone
//lets place the camera behind the player
vec_for_angle (camera.x, player.pan); //returns a direction vector (values will vary from -1 to 1)
vec_normalize (camera.x, distance); //now we stretch the camera backwards (assuming distance = -500;)
vec_add (camera.x, player.x); //now add to player position so we are behind it
camera.z = player.z + 800; //and we pretend to be a bird, high in the sky
//facing camera to player
vec_set (temp.x, player.x);
vec_sub (temp.x, camera.x); //substract camera position from player, so we have a player-facing direction vector
vec_to_angle (camera.pan, temp.x); //calculate the angle from the direction vector and let the camera face the player
wait(1);
}
...