可以试试用下面的方法检测碰撞
bool CheckCollider(Vector3 a, Vector3 b, float range)
{
if (Mathf.Abs(Mathf.Abs(a.x) - Mathf.Abs(b.x)) <= range && Mathf.Abs(Mathf.Abs(a.x) - Mathf.Abs(b.x)) >= 0 &&
Mathf.Abs(Mathf.Abs(a.y) - Mathf.Abs(b.y)) <= range && Mathf.Abs(Mathf.Abs(a.x) - Mathf.Abs(b.x)) >= 0 &&
Mathf.Abs(Mathf.Abs(a.z) - Mathf.Abs(a.z)) <= range && Mathf.Abs(Mathf.Abs(a.x) - Mathf.Abs(b.x)) >= 0)
{
return true;
}
else
{
return false;
}
}