1
votes

Can we detect mesh collision in unity3d? I want to show some texture on collision, currently I am using box colliders, that's why its surface/edge do not match with the object body mesh, Also even if I get the hit point on the surface of mesh, I don't know how to put a texture on a mesh at specific position over mesh, is there any in-built component specific for the same kind of requirement or a workaround of this in unity3d?

enter image description here

As we can see in picture the collision has been detected inside the game object because the box collider is inside the target object mesh Note: here the actual mesh I have replaced with a dummy cube mesh

But is there any way to detect when bullet collider/mesh was actually going through the mesh of the target object as in below image I have shown where exactly I want to detect the hit point between target object mesh and bullet mesh/collider also how to draw a texture over here (the hit point on the mesh).

enter image description here

1

1 Answers

1
votes

Short answer: No

Because that's not how that works.

Long answer:

If you want the mesh to be used as the collider, you should set the mesh as the target for a MeshCollider component. However, mesh colliders are very expensive: Unity needs to recalculate them every time they move, scale, rotate, or otherwise change their boundaries.

There is, however this asset which will perform raycasts against the renderer mesh, without the need for a collider, but I have no idea what kind of performance hit that will have.