ENTITY* temp_ent;
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);
if(HIT_TARGET)
{
if (hit.entity!=NULL)
{
if(temp_ent!=NULL) // undo translucent for previous entity
{
reset(temp_ent,TRANSLUCENT);
temp_ent.alpha = 100;
}
temp_ent=hit.entity;//handle for previous entity
set(hit.entity,TRANSLUCENT);
hit.entity.alpha = 60;
}
}
else //if no target, undo translucent for previous entity
{
if(temp_ent!=NULL)
{
reset(temp_ent, TRANSLUCENT);
temp_ent.alpha = 100;
}
}
wait(1);
}
}