Ultimate fix: force gigantic colliders to counteract extremely small lossyScale of parent

This commit is contained in:
yangbear
2026-07-12 05:02:22 +08:00
parent 0fa8ba1169
commit 3ca4dcca6f
+10 -6
View File
@@ -24,18 +24,22 @@ public class PingClickHandler : MonoBehaviour
col = box;
}
// 终极修复:直接无视它原来的任何比例,强制改成非常庞大的数值!
// 因为你的模型在世界坐标里 lossyScale 达到了 100x73x100,所以局部半径会被算得很小(0.006)。
// 现在我直接给它一个固定的局部半径 = 1.0f。在放大 100 倍后,这个球的大小就是 100 米长!
// 这绝对绝对不可能点不到了。
if (col is SphereCollider sphere)
{
sphere.radius = 1.0f;
sphere.radius = 2.0f;
}
else if (col is BoxCollider box)
{
box.size = new Vector3(2f, 2f, 2f);
box.size = new Vector3(4.0f, 4.0f, 4.0f);
}
else if (col is CapsuleCollider cap)
{
cap.radius = 1.0f;
cap.height = 2.0f;
cap.radius = 2.0f;
cap.height = 4.0f;
}
col.isTrigger = false;
@@ -87,13 +91,13 @@ public class PingClickHandler : MonoBehaviour
{
if (!_isBlinking) return;
// 遍历所有激活的相机发射射线(解决 camera3 不是主相机导致点不到的问题!)
foreach (var c in Camera.allCameras)
{
if (!c.enabled) continue;
Ray ray = c.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hits = Physics.RaycastAll(ray, 100f);
// 使用超长射线,无视距离
RaycastHit[] hits = Physics.RaycastAll(ray, 10000f);
foreach (var hit in hits)
{
if (hit.collider != null && hit.collider.gameObject == gameObject)