private float GetRayAngle(Ray ray)
{
RaycastHit hit = new RaycastHit();
Physics.Raycast(ray, out hit, Mathf.Infinity);
Vector3 vector = hit.point - Camera.main.transform.position;
return Mathf.Atan(vector.y / vector.x) * Mathf.Rad2Deg;
}
the result of the function ends up rounding to 90 degrees when the actual angle is 30 degrees from 90 degrees, but gives the actual value when Vector3 vector is within a certain range of distances from the center point