When RigidBody On, Raycast don't work!

当我将 Rigidbody 组件添加到 Gameobject 时,此代码将不会进入。而当我删除 Rigidbody 组件时,此代码将正常工作。
虽然我找到了Rigidbody的原因,但我想知道这样做的理由,谢谢。

我用来获取游戏对象的代码:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hitInfo)) …


hey… why I’m posted become to chinese?
anyway, It looks like work just fine when I’m turn the Rigidbody’s IsKinematic ON
not sure exactly why, but it appears to be resolved.

The body type won’t change how raycast or any physics queries work; they detect colliders not rigidbodies. It’ll be some other logic in your scripts or you moving it somehow and it not actually being where you think it is.

The forums don’t do this so it’s whatever you posted. It’ll also cause it to go to moderation btw.

1 Like