//22求二位向量夹角(0-360度)
float Angle(Vector2 form, Vector2 to)
{
float x =to.x-form.x ;
float y =to.y-form.y;
float hy = Mathf.Sqrt(Mathf.Pow(x, 2) + Mathf.Pow(y, 2f));
float cos = x / hy;
float radian = Mathf.Acos(cos);
float angle = 180 / (Mathf.PI / radian);
//if (x <= 0 && y > 0) angle = 180 - angle;
//if (x <= 0 && y < 0) angle = 180 + angle;
//if (x > 0 && y <=0) angle = 360 - angle;
if (y < 0) angle = 360 - angle; // if (y < 0) angle = - angle; //-180-180
else if ((y == 0) && (x < 0)) angle = 180;
return angle;
}
2D ui 向量指向问题
private List<Vector2> footPointList;
RectTransform go = Instantiate(prefabfoot);
go.transform.SetParent(footParent);
go.right = footPointList[footPointList.Count - 1] - footPointList[footPointList.Count - 2];//当前坐标减去上一个坐标