Hi.
Because its almost the same question...

Heres a simple ( but well working...i guess ^^ ) 3rd person cam controller which takes care of walls and obstacles via c_trace. Maybe u need to play around with campos1 and campos2 values to fit ur needs. Thanks to SuperKu, cause he provited me the required tips for the c_trace part a few month ago. If uve optimized something, POST U MISER(S) ! grin

Code:
// 3rd person cam controller written by rayp 2013
// -------------------------------------------------------------------------------------------------------------------------------------------------
var cam_lerp = 0;  // global!
void _handle_cam_3rdperson(){
   VECTOR cam_pos1,cam_pos2;
   var i;
   // -------------------------------------------------------------------
   vec_set(cam_pos1,vector(-300, 0, 5)); // First cam pos
   vec_rotate(cam_pos1,vector(player.pan,camera.tilt-15,0));
   vec_add(cam_pos1,player.x);
   // -------------------------------------------------------------------
   vec_set(cam_pos2,vector(-20, 0, 30)); // Second cam pos  
   vec_rotate(cam_pos2,vector(player.pan,-5,0));
   vec_add(cam_pos2,player.x);
   // -------------------------------------------------------------------
   //if u handle cam tilt/pan + playerpan somewhere else remove the following four lines. Its pan and tilt handling, not more.
   //turn player via mouse mickey.x
   c_rotate(me, vector(-mickey.x * time_step / 4,0,0), IGNORE_ME | IGNORE_PASSABLE | IGNORE_SPRITES | USE_POLYGON | GLIDE);
   //set cam pan 2 player pan
   camera.pan = my.pan;
   camera.tilt += mickey.y * time_step;
   camera.tilt = clamp (camera.tilt, -45, 45); //not tested play around with the values here
   // -------------------------------------------------------------------      
   trace_mode = IGNORE_ME | IGNORE_PASSABLE | IGNORE_SPRITES | USE_POLYGON;   
   c_ignore (1, 0); // cam ignores the player
   i = c_trace(cam_pos2,cam_pos1, trace_mode); //trace from campos to campos
   if(!trace_hit) i = 1;
   else i = i/vec_dist(cam_pos1,cam_pos2);      

   if (i < 0.1) set  (player, TRANSLUCENT); //very close to player? set him transparent
   else         reset(player, TRANSLUCENT); //far away reset transparent
   // -------------------------------------------------------------------
   //calculate camera pos
   i = i / 3;
   cam_lerp = minv(cam_lerp+0.125*time_step,i);
   vec_lerp(camera.x,cam_pos2,cam_pos1,cam_lerp);//at the end set camera x
}
// -------------------------------------------------------------------------------------------------------------------------------------------------



Example call in your project
Code:
void move_player(){
   player = me;
   my.group = 1; 
   ...
   ..
   while (1){     
      ...
      ..
      c_move()
      _handle_cam_3rdperson();
      ..
      ...
      wait (1);
   }
   ..
   ...
}

...when copy and pasting at least credits would be nice

edit:
Its not good to turn player via c_rotate ( dont know why i wrote it in the code ). Use "player.pan += ..." instead. When using c_rotate, player will stuck while looking around, in some situations.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;