#Signed Angle flips randomly

3 messages · Page 1 of 1 (latest)

iron granite
#

i'm very new to non visual scripting in general (my third day) i want to get angle between input direction and where character is facing (3d third person game) to play turning animations, so i need it in + and - to determin left and right

$InputDir/InputDirPos.global_translation.signed_angle_to($Mesh/MoveDirPos.global_translation, Vector3.UP)

(meshes are for visualisation) black sphere is for input direction, and white sphere is for where character facing

and finally the problem, when i just walk around in circles angle just randomly switches from + to - and i have no idea why, i tried different sppeds for input and character facing thinking that maybe input just went too far, but nope, it doesn't matter if angle is 5 degree or 90, and it seems to be related to global position

iron granite
#

ok, so the issue was i was getting the angle from position vectors while i shoul have been getting it from direction vectors

#

and for anyone with the same issue Direction vector from point A to point B is calculated by subtracting the position of B from the position of A.