you could save a reference to the mesh/collider components, could help but i don’t think it this can be the problem in your case.
MeshCollider collider;
MeshFilter filter;
void start() {
collider = hitTransform.Getcomponent<MeshCollider>();
filter = hitTransform.Getcomponent<MeshFilter>();
}
// your line of code:
collider.sharedMesh = filter.sharedMesh;
this is the only thing i can see right away you could improve, not sure if changing a meshCollider has any special effects on framerate… did u try use the profiler to figure out what might cause this?
Ive done pooling tests with colliders before and other than wheel colliders exponential performance hits were taken when removing a group of 2d colliders or adding a group of ‘normal’ colliders
u might want to disable the collider before you make changes and enable it again when you are done (using a temporary copy maybe?)