start particles when object moves

hello, I have boat object and moving it with slider. I created a particle effect bow wake, I want this effect to work when the ship is moving and stop when it stops. How do i create script for this. I tried a few ways but did not get any results. I would be glad if you help. Thank you.

All you need to do is add the particle to the script and tell it to play and stop when you need to.

public class YourClass : MonoBehaviour
{
    public Rigidbody rb;
    public ParticleSystem bowWake;

    private void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    private void Update()
    {
        Vector3 v3Velocity = rb.velocity;
        if (v3Velocity.z != 0)
        {
            StartBowWake();
        }
        else
        {
            StopBowWake();
        }
    }
    void StartBowWake()
    {
        bowWake.Play();
    }
    void StopBowWake()
    {
        bowWake.Stop();
    }
}

it works great, i am grateful for your help. :slight_smile: