검색결과 리스트
글
Vector3.Angle을 사용, 하지만 각도가 90도 이내로만 나온다.(0~360도 사이의 값으로 각도를 구하고 싶다면 문제가 됨)
이에 대한 해결책은 아래와 같다
http://forum.unity3d.com/threads/31420-Left-Right-test-function
http://answers.unity3d.com/questions/18105/how-to-calculate-the-angle-between-two-vectors
public float ContAngle(Vector3 fwd, Vector3 targetDir) { float angle = Vector3.Angle(fwd, targetDir); if (AngleDir(fwd, targetDir, Vector3.up) == -1) { angle = 360.0f - angle; if( angle > 359.9999f ) angle -= 360.0f; return angle; } else return angle; } public int AngleDir( Vector3 fwd, Vector3 targetDir, Vector3 up) { Vector3 perp = Vector3.Cross(fwd, targetDir); float dir = Vector3.Dot(perp, up); if (dir > 0.0) return 1; else if (dir < 0.0) return -1; else return 0; }참고 사이트: http://blog.naver.com/sdragoon/150108963945
http://forum.unity3d.com/threads/31420-Left-Right-test-function
http://answers.unity3d.com/questions/18105/how-to-calculate-the-angle-between-two-vectors
RECENT COMMENT