- Home /
How to pierce a plane?
Hello, i have made a plane, like a false barrier, and i want to pierce that plane with an other game object. But also i want that the collision with that plane results in the script. Thanks.
Answer by rainChu · Aug 16, 2018 at 07:53 PM
It's a little bit hard to understand what you're asking, but I think what you want is a Box Collider set to act as a trigger. Attach a box collider to your plane. Don't add a mesh collider for this, because you can't use a non-convex mesh collider as a trigger in this way. Make the collider a little bit thick, you don't want it to be 0 width. If you're going to have something very fast pass through it, you may need to use continuous collision detection instead of discrete.
Then, you can use OnTriggerEnter to check when it's been pierced. If you need the hit normal, it's a bit trickier, but possible by setting up a raycast. Let me know if this helps!
You're welcome! If this works, please mark my response as the answer so I'm credited. If it doesn't work, let me know and I'll try my best to help.
But when i create a box collider for a plane, the box collider doesn't permit to make the box a little bit thick (the box is fixed in a flat box).
You might have to play around with the "Size" setting in the box collider component, in the inspector window. I've set this thickness to 0.5: https://rainChu.com/s/k1.png
You might also want to remove the collider that comes with the plane, if it has one by default: https://rainChu.com/s/Vt.png