Does anyone know of alternatives to Unity’s existing system for Raycasts? I’m looking for one that would seek out MeshRenderer components instead of Colliders.
Reason why is that we want a raycast to effect stage geometry, but the way our stages are set up features colliders contained in totally different parents than the actual art assets for the stage.
We’re doing this in some instances by adding the mesh colliders to the mesh renderers, doing the raycasts, and removing the mesh colliders again.
You’ll have to notify the physics system that the collider has been created, though. Usually you’d do that by setting the object dirty, but if that’s not wanted, you can just wiggle the transform. Here’s a snippet from how I solve this issue:
Use layers and layermasks to avoid hitting the level colliders you’re using. You can also raycast directly against a single collider with the Collider.Raycast method.