unity calculate angle between two points code example
Example 1: unity rotation between 2 points
transform.rotation = Quaternion.FromToRotation(Vector3.up, v3Pos2 - v3Pos1);
Example 2: get angle between two vectors unity
Vector3 targetDir = target.position - transform.position;
float angle = Vector3.Angle(targetDir, transform.forward);
Example 3: check the angle between two game objects unity
Vector3 dir = GameObject1.position - GameObject2.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;