image.png
void SelfPos()
{
Vector3 delta = target.position - transform.position;
//判断前后
if (Vector3.Dot(transform.forward, delta)>0)
Debug.Log("在前方!!!");
else
Debug.Log("在后方!!!");
//判断左右
if (Vector3.Dot(transform.right, delta) > 0)
Debug.Log("在右方!!!");
else
Debug.Log("在左方!!!");
if (Vector3.Dot(transform.up, delta) > 0)
Debug.Log("在上方!!!");
else
Debug.Log("在下方!!!");
}