The turret has to aim to mouse3d_vec
after turning you have to do the clamping
Code:
action b_gun()
{
  // set(my,PASSABLE);
  VECTOR temp;
  while(my)
  {
    vec_for_vertex(me.x, basic, 365);
    vec_to_angle(my.pan,mouse_dir3d);
    vec_set(temp,mouse_dir3d);
    vec_scale(temp,1000); // set a range
    vec_add(temp,mouse_pos3d);
    c_trace(mouse_pos3d,temp,IGNORE_MODELS|IGNORE_SPRITES);
    vec_set( mouse3d_vec , target );

    vec_diff( temp , me.x , mouse3d_vec );// may need to exchange me.x and mouse3d_vec
    vec_to_angle( my.pan , temp );

    my.tilt = clamp(0, my.tilt, 0);
    wait(1);
  }
}


muffel

Last edited by muffel; 02/13/11 13:44.