Physics.SphereCast不会检测已经在半径内的碰撞!!!
加个容错
private bool SphereCast(Vector3 _originPos,Vector3 _targetPos,out RaycastHit hit,LayerMask _layerMask) { Vector3 dir = (_targetPos - _originPos).normalized; float radius = GetRadius(); float distance = Vector3.Distance(_targetPos, _originPos); Vector3 adjustOriginPos = _originPos - dir * radius; if (Physics.SphereCast(adjustOriginPos, radius, dir, out hit, distance, _layerMask)) { return true; } else { return false; } }