I'm trying to trigger an event when my golf ball goes through an object. I've created a customized object using Maya, imported the object and gave it a mesh collider, then checked "is trigger." The problem is, the ball doesn't actually set off the trigger! I've checked to make sure the obect is tagged correctly. The golf ball has a sphere collider on it as well as a rigid body.
The only way to set off the trigger is for me to set the customized object to "convex". Even then, the golf ball doesn't go through it, it just collides with it (a result that I do not desire). Isn't convex only neccessary if BOTH objects have mesh colliders? Or do I need to use convex if I have one mesh collider and one sphere collider? Does anybody see a mistake or something I'm overlooking here?
Answer by Tseng
Oct 06, 2011 at 10:54 PM
This depends. You haven't told what shape your mash has? Is your mash a kind of a ring?
If it's a ring and your ball shoots through the mesh, then it's obvious, why it doesn't trigger, because the ball doesn't touch the mesh at all, when it goes exactly through the hole. When you check "convex" collider however, the hole disappears and becomes "solid" (you can see this, when you closer inspect it, you'll notice that the green collider lines go though the middle of your mesh).
Convex basically closes holes. I'll post an image of an example soon
As you can see, the convex mesh is much simpler than the actual mesh and will even trigger on areas where no mesh is there.
Golf balls are kind of tiny. Do you think the problem might be because of it 'phasing' through between physics steps?
Dunno, but you can check this in the frame-by-frame feature. If it passes through the collider from one frame to the other, without touching the collider, it's probably the too fast thing.
What shape is the mesh you're using?
Answer by Tim.Holman
Oct 07, 2011 at 10:19 PM
My mesh is a totally unique object that was custom built to fit into an oddly shaped sand bunker (I'm working on a golf mini game). There are no holes in the mesh as mentioned by Tseng. I will look into using the frame by frame feature to figure out if it is in fact moving to fast. If this is the case though, wouldn't setting the Collision Detection (under rigid body) to continuous fix the problem? Or perhaps continuous dynamic?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
4 People are following this question.
Can't click gameobject when over another trigger?
OnTriggerEnter is not running! Need help with collision.
Box Trigger and Mesh Collider on one object.
What Space Partitioning is used for Sphere Collider Triggers?
check when a projectile that is a trigger hits a mesh that is also a trigger