向量的点乘方法Dot,叉乘方法Cross
向量与向量不能除,没有意义
点乘又称“点积”或“内积
点乘最后的结果是一个float
几何意义: a.b=|al.|b|cos<a,b>
点乘只能拿0~180度之间
//向量的点乘
public Transform t1;
public Transform t2;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float dot = Vector3.Dot(t1.position.normalized, t2.position.normalized);
//计算夹角
float angle = Mathf.Acos(dot) * Mathf.Rad2Deg;
//如果两个向量的夹角大于60则
if(angle>60)
{
}
Debug.DrawLine(Vector3.zero, t1.position);
Debug.DrawLine(Vector3.zero, t1.position);
Debug.Log(angle);
}