Recently I have found different solution, that is best for flat surface. The idea is to close our complex mesh in primitive collider and try two Collider.Raycast on every object that had trigged it. We can shot first Collider.Raycast from our incoming object collider to our complex mesh. It gives as point from we can shot another raycast and gives as position where object would hit surface (at moment!). When we shot second ray to our incoming object, distance of that second ray is value between object and our trigger (mesh collider). If second Raycast return false (what basically means that distance is <=0) it had to be a touch event.
NOTE: Better our primitive fits the complex mesh, better performance we get, since less rays have to be cast.
↧