我需要一些帮助。我有一部分代码可以用 raycast 搜索未阻塞的邻居。我需要获得与“WP”标签发生冲突的光线投射。两次迭代都显示了正确的结果,转储和光线投射也是如此,光线投射确实成功碰撞了一些东西,但是当我检查光线投射碰撞的东西时,没有显示结果....任何人都知道这有什么问题代码..??
int flag = 0, flahNeigh = 0;
for(flag = 0; flag< wayPoints.WPList.Length; flag++) // iteration to seek neighbour nodes
{
for (flagNeigh = 0; flagNeigh < wayPoints.WPList.Length; flagNeigh++)
{
if (wayPoints.WPList[flag].loc != wayPoints.WPList[flagNeigh].loc) // dump its own node location
{
if (Physics.Raycast(wayPoints.WPList[flag].loc.position, wayPoints.WPList[flagNeigh].loc.position, out hitted)) // raycasting to each node else its self
{
if (hitted.collider.gameObject.CompareTag("WP")) // check if the ray only collide the node
{
print(flag + " : " + flagNeigh + " : " + wayPoints.WPList[flagNeigh].loc.position); // debugging to see whether the code works or not (the error comes)
}
}
}
}
}
感谢您的赞赏和回答...对不起,如果我的英语不好...^^