- float angle_360(Vector3 from_, Vector3 to_)
- {
- //两点的x、y值
- float x = from_.x - to_.x;
- float y = from_.y - to_.y;
- //斜边长度
- float hypotenuse = Mathf.Sqrt(Mathf.Pow(x,2f)+Mathf.Pow(y,2f));
- //求出弧度
- float cos = x / hypotenuse;
- float radian = Mathf.Acos(cos);
- //用弧度算出角度
- float angle = 180 / (Mathf.PI / radian);
- if (y < 0)
- {
- angle = -angle;
- }
- else if ((y == 0) && (x < 0))
- {
- angle = 180;
- }
- return angle;
- }