bonerotate to face camera - only working at certain angles

Posted By: Stansmedia

bonerotate to face camera - only working at certain angles - 08/31/14 22:47

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);

Posted By: txesmi

Re: bonerotate to face camera - only working at certain angles - 09/01/14 08:40

Hi,
try using the -180<->180 range on angles substraction result. I did not test it.

Code:
bone_angle.pan = clamp(ang(temp_angle.pan), -90, 90);
bone_angle.tilt = clamp(ang(temp_angle.tilt), -90, 90);
bone_angle.roll = 0;



I hope it helps.
Salud!
Posted By: Stansmedia

Re: bonerotate to face camera - only working at certain angles - 09/01/14 17:49

Looks like it did the trick! Good ol' ang(...) to the rescue. lol
© 2024 lite-C Forums