Vector3 tempVec = Vector3.Cross(transform.forward, target.transform.position - transform.position);
float value = Vector3.Dot(transform.up, target.transform.position - this.transform.position);
if (tempVec.y > 0 && value > 0)
{
// 表示敌人在角色的右边(根据上图的左手定则)
Debug.Log("右上");
}
if (tempVec.y < 0 && value > 0)
{
Debug.Log("左上");
}
if (tempVec.y > 0 && value < 0)
{
// 表示敌人在角色的右边(根据上图的左手定则)
Debug.Log("右下");
}
if (tempVec.y < 0 && value < 0)
{
Debug.Log("左下");
}
Unity----判断敌人在自身角色哪个方位
最新推荐文章于 2023-07-31 09:14:46 发布