public static float GetDegreeBtwVectors(Vector3 aVec, Vector3 bVec, Vector3 upVector) { var dirNum = GZ_Math.GetAngleDir(aVec, bVec, upVector); float angle = Mathf.Acos(Vector2.Dot(aVec.normalized, bVec.normalized)) * Mathf.Rad2Deg; if (dirNum == 1) { angle = 360 - angle; } return(angle); }
public bool SelectTile(ref GZ_Player player) { #if UNITY_EDITOR Debug.DrawLine(Vector3.zero, _debugHittedPos, Color.red); #endif RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); bool result = false; if (Physics.Raycast(ray, out hit)) { #if UNITY_EDITOR _debugHittedPos = hit.point; #endif //find proper column var tarVec = hit.point - this.transform.position; var dirNum = GZ_Math.GetAngleDir(this.transform.up, tarVec, this.transform.forward); float angle = Mathf.Acos(Vector2.Dot(tarVec.normalized, this.transform.up)) * Mathf.Rad2Deg; if (dirNum == 1) { angle = 360 - angle; } int matchColumn = (int)(angle / AngleOffset); //find Row for (int r = 0; r < _tileArray.GetLength(0); r++) { result = _tileArray[r, matchColumn].CheckDistance(tarVec.magnitude); if (result) { _tileArray[r, matchColumn].SetInfomation(ref player); return(true); } } } return(result); }