Im using Unity and developing a game,which when a laser hit the object with the tag "gems" and it will be destroyed.Here's my code:
```
//Handle ray reflection
Ray ray = new Ray(position, direction);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, laserMaxLength, reflectionMask))
{
Vector3 reflectDirection = Vector3.Reflect(direction, hit.normal);
lineRenderer.positionCount = ++pointCount;
lineRenderer.SetPosition(pointCount - 1, hit.point);
position = hit.point;
direction = reflectDirection;
Check(hit.collider.gameObject);
}
else
{
lineRenderer.positionCount = ++pointCount;
lineRenderer.SetPosition(pointCount - 1, position + direction * laserMaxLength);
break;
}
//Handle Collision with Gems
if (Physics.Raycast(ray, out hit)) {
if(hit.collider.gameObject.tag=="gems"){
Destroy(hit.collider.gameObject);
}
}
```
however it is not working!my gem contains a mesh collider with Convex set to true only.
Pls help!