Anybody know how to fix this problem? The head faces the camera at certain angles, but then it hits a point and it stops working. I've been searching the forum for a little while trying to find a solution but have not had any luck.

Code:
ent_bonereset(my,"head");
vec_for_bone(bone_pos.x,my,"head");
vec_set(temp_vec,camera.x);
vec_sub(temp_vec,bone_pos.x);
vec_to_angle(temp_angle,temp_vec);
vec_sub(temp_angle, my.pan);
bone_angle.pan = temp_angle.pan;
bone_angle.tilt = temp_angle.tilt;
bone_angle.roll = 0;
bone_angle.tilt = clamp(bone_angle.tilt, -90, 90);
bone_angle.pan = clamp(bone_angle.pan, -90, 90);
ent_bonerotate(my,"head",bone_angle);



Decessus - 80% done. 100% abandoned.
GET MY ANDROID GAME! https://play.google.com/store/apps/details?id=com.lasertrain.zspinballfree&hl=en