I’ve got a weird issue in a new project: I used to raycast objects without rigibodies from my First-person view rigidbody character controller:
Physics.Raycast(new Ray(camerRayOrigin, transform.forward), out RaycastHit hit, rayDistance, interactLayers,QueryTriggerInteraction.Collide)
However, in my new project this wouldn’t work until I add a rigidbody to the target collider.
has anyone have an idea about what could be the issue?
2/ I thought about adding a KINEMATIC rigidbody to each target collider (they are usually static colliders). But, I wonder what is the performance impact of such solution? I’m targeting low end devices like mobile devices.
Raycasts should have no problem hitting colliders with or without a Rigidbody. The Rigidbody isn’t really relevant. Maybe share a little more context about what you’re doing here and some more code? For example how is your layermask set up? What layer(s) are the collider(s) you are trying to hit on? Etc…
thanks for the confirmation, I found the issue, it all comes down to using hit.transform.gameObject instead of hit.collider.gameObject in a context where the target collider is a child of a root object that has a kinematic rigidbody