- Home /
Surface with hole and Raycast - Which collider
Hi everyone,
I would like to know what is the best solution. Here is the setup :
A wall of a face with a hole
A bunch of objects behind
A Raycast to select object
What kind of collider should I use for the wall ?
The most optimized solution is a Box collider but how can I handle the hole ? A mesh collider is not the most optimized solution especially with Raycast.
Is there a way to set-up automatically multiple Box collider to match the shape of the wall and the hole ?
Thanks a lot !
Answer by Tomer-Barkan · Apr 15, 2015 at 02:17 PM
In this case i would recommend a box collider for the wall, and a separate collider for the hole (preferably a basic collider for performance, like flat sphere or another box).
Then use RaycastAll instead of Raycast, and have the wall and hole colliders negate each other. So if you hit both of them, treat it like hitting none. That way any raycast going through the hole, it will hit both, and be treated as if it went through.
Your answer
Follow this Question
Related Questions
Make Ray hit own collider 1 Answer
Prevent shooting when gun is inside wall 1 Answer
Collider Vision AI question. Solved! 0 Answers
raycasts only working with IsTrigger colliders? 1 Answer
Raycast and colliders problem. Corners of two colliders 0 Answers