I can't seem to get the camera behind the player. But every thing else apart from the camera position works fine. At the moment the camera is facing the side of the player instead of it being behind the player.

This is the code that I use, is there something wrong?



function camera_follow(ENTITY* chrac)
{
while(1) {
vec_set(camera.x,vector(-250,-45,45)); // camera position relative to the player
vec_rotate(camera.x ,chrac.pan); // rotate the camera position with the player
vec_add(camera.x,chrac.x); // add player position
vec_set(camera.pan,vector( chrac.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}

action player_1() // control the player
{

camera_follow(my);


VECTOR vFeet;
vec_for_min(vFeet,my); // vFeet.z = distance from player origin to lowest vertex
my.STATE = 1;
var walk_speed = 0;
var stand_speed = 0;
var run_speed = 0;

while (1)
{
stand_speed += 2*time_step;
ent_animate(me,"Stand",stand_speed,ANM_CYCLE);

// state 1: walking ////////////////////////////////////////////
if (key_cuu)
{
// rotate the entity with the arrow keys
my.pan += (key_cul-key_cur)*5*time_step;

// move the entity forward/backward with the arrow keys
var distance = (key_cuu-key_cud)*5*time_step;
c_move(me, vector(distance,0,0), NULL, GLIDE);

// animate the entity
walk_speed += 1.5*distance;
ent_animate(me,"Walk",walk_speed,ANM_CYCLE);

// adjust entity to the ground height, using a downwards trace
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME | IGNORE_PASSABLE);
my.z = hit.z - vFeet.z; // always place player's feet on the ground


}

wait(1);
}

}


function main()
{
video_mode = 7; // 800x600 pixels
level_load ("terrain.wmb");
ent_create("MainCharacterBonesAtt.mdl", vector(-3072, 1741, -97), player_1);
wait (2);


}


Please help thanks