【发布时间】:2014-12-15 19:45:35
【问题描述】:
我使用http://www.theappguruz.com/tutorial/draw-line-mouse-move-detect-line-collision-unity2d-unity3d/ 的线路碰撞代码,它工作正常。它检测线何时与自身发生碰撞,但我需要检查与其他对象的碰撞(比如说一个平台)。我在脚本中添加了这个函数:
private bool isLineCollidedWithOtherObject()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(pointsList[pointsList.Count-1]));
if(Physics.Raycast(ray,out hit))
{
if(hit.collider)
return true;
}
return false;
}
并在检查碰撞时添加
if(isLineCollide() && isLineCollidedWithOtherObject());
但它不起作用。我将Box2dcollider 添加到平台(播放器)。我做错了什么?
【问题讨论】:
标签: android unity3d collision-detection