How can I make the explosions I have on a object spawn on the mesh

I am not trying to destroy the object, I am just looking how to make the “explosion”
instances blow up on the outer mesh. I am shooting at it with a gun and just want to see random explosions once in a while.
I was thinking a rand type of function but I dont know what function I use to get the GameObject mesh.

You’d have to find a random triangle in the mesh, then find a random point in that triangle.

int triangle = Random.Range(0,mesh.triangles.Length / 3) * 3;

Then your three verices are mesh.vertices[triangle], [triangle+1], and [triangle+2].

There are a few ways to get an object’s mesh; the easiest way is probably gameObject.GetComponent().mesh, but check out the script reference too.

Edit - Sigh, and after “GetComponent” you need a Less Than symbol, then “MeshRenderer”, then a Greater Than symbol.

you could attach the explosion to the bullet you are firing, you can then get it to explode on impact on anything by instantiating the explosion where the bullet is at the collision then just destroying the bullet.