Toggling particles on/off when something is attached to object's socket

Hello all!

In my VR setting, I have a skillet with a socket. When the user adds a piece of food to the socket, I need it to trigger the particle system. Currently when I go into the VR setting, the particles are already on when they should on be on when something is in the socket. I have also tried putting the particles.Stop(); within the start method

Here is my script:

using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class ParticleFryPan : MonoBehaviour
{
    public ParticleSystem particles;   
    XRSocketInteractor xRSocketInteractor;
    
    void Start()
    {
        particles = GetComponent<ParticleSystem>();
    }

    void Update()
    {
        particles.Stop();
        xRSocketInteractor = GetComponent<XRSocketInteractor>();
        if (xRSocketInteractor != null && xRSocketInteractor.socketActive)
        {
           particles.Play();
        }
    }
}

Everything that is in the Update Method without a condition will execute every frame of your application.

Having

    void Update()
    {
        particles.Stop();
     }

Without a condition to execute it will make it a permanent method happening every frame of your application, because of that there is no way the particles will ever play/stop playing.

Remove the conditions from the Update method and make them variables.

Use ParticleSystem isPlaying as a reference and DON’T check them in the Update Method, make them trigger by a action that happened.

Example: Food entered contact with Skillet, this means I need to check if we have a socketActive and consequently a ParticleSystem playing.