Smoothing collision rate

Hi there !
I have that script that plays an audio clip, and instantiate a particle effect, on collision point, between two moving gameobjects.

Each time the two gameobjects collide, 5 to 10 clones of the particle effect are spawned, like a continuous detection each frames, wich causes huge fps drops at some points.

Is there any way to add some sort of “lazyness” to the collision detection rate only for these two gameobjects ?

public ParticleSystem particleSystem;
public AudioClip soundClip;
public AudioSource audioSource;
public float volume = 1.0f;
    
void OnCollisionEnter(Collision collision){
	audioSource.PlayOneShot (soundClip, volume);
	ContactPoint contact = collision.contacts[0];
	ParticleSystem clone = (ParticleSystem)Instantiate (particleSystem, transform.position, Quaternion.identity);
	}
}

Feel free to say anthing about the script, i’m pretty new to this.

Hi @Cepeka ,

In the past I’ve had luck with testing for the velocity of the collision, so your code will only be triggered if the collision is strong enough - For example:

void OnCollisionEnter(Collision collision){
     if (collision.relativeVelocity.magnitude > 2)
     {
          audioSource.PlayOneShot (soundClip, volume);
          ContactPoint contact = collision.contacts[0];
          ParticleSystem clone = (ParticleSystem)Instantiate (particleSystem, transform.position, Quaternion.identity);
     }
 }