Posted By: Blobfist
determine relative angle - 04/16/18 20:49
I am playing around with angles and ran into a little thought error.
The actual moving character is the transparent box, while the animated model is simply attached to it.
The box always faces in the direction of where it is moving, while the animated character faces towards it`s enemy.
The attached character should play in relation to the angle of the transparent box the correct walking animation (strafe forward, left, right, back).
This is my attempt:
I can correctly define when the character is facingin the same or opposite direction as the box it is attached to.
However, determining if it is facing to the left or the right side, does not seem to work.
Could anybody point out my error?
The actual moving character is the transparent box, while the animated model is simply attached to it.
The box always faces in the direction of where it is moving, while the animated character faces towards it`s enemy.
The attached character should play in relation to the angle of the transparent box the correct walking animation (strafe forward, left, right, back).
This is my attempt:
Code:
//calculate angle relation between [b]my[/b] and [b]enemy[/b] var target_ang = abs(ang(bbox.pan - my.pan));
I can correctly define when the character is facingin the same or opposite direction as the box it is attached to.
Code:
//if ((target_ang >= 0) && (target_ang < 45))//facing within 45 degrees the same direction //if ((target_ang >= 135) && (target_ang < 180))//facing within 45 degrees the opposite direction
However, determining if it is facing to the left or the right side, does not seem to work.
Code:
if ((target_ang >= 45) && (target_ang < 90))//facing within 45 degrees the left if ((target_ang >= 90) && (target_ang < 135))//facing within 45 degrees the right
Could anybody point out my error?