- Home /
Vector3.SignedAngle changes sign for no reason
Relevant code:
Vector3 cameraRelFaceDir = Vector3.ProjectOnPlane(camera.forward, transform.up).normalized;
float anglePlayerForwCameraForw = Vector3.SignedAngle(cameraRelFaceDir, transform.forward, Vector3.forward);
Debug.Log("angle: " + anglePlayerForwCameraForw + ", transf up: " + transform.up + ", transf forw: " + transform.forward + ", camera rel dir: " + cameraRelFaceDir);
This clearly shows that it changed sign between two frames. (The image doesn't seem to show up correctly so here's the link: https://ibb.co/pP7xTdK)
Comment
Best Answer
Answer by Boti97 · Oct 29, 2020 at 09:17 AM
I figured it out. The third parameter was wrong, since it should be a normal of the plane which the from and to vectors are on. The interesting thing is that it worked almost perfectly, except that little glitch that it sometimes changed the sign.
Your answer
![](https://koobas.hobune.stream/wayback/20220613014738im_/https://answers.unity.com/themes/thub/images/avi.jpg)