# Stop event with game object destroy?

**URL:** <https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833>\
**Category:** Unity\
**Created:** [June 1, 2020, 2:31pm UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833 "2020-06-01T14:31:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeathClose](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/heathclose/32/1227_2.png) [@HeathClose](https://qa.fmod.com/u/HeathClose)\
**Post date:** [June 1, 2020, 2:31pm UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/1 "2020-06-01T14:31:47Z")

</div>

This should be straight forward but it is not working. I have a projectile gets instantiated and destroys itself after impact… but the sound (which is longer than the projectile can last) keeps playing… so eventually there are LOTS of them playing… What am I doing wrong?

![Screen Shot 2020-06-01 at 9.30.03 AM](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/719d8474a9b043d8e79a05dee9e2ca2f095c51b1.png)

 ![Screen Shot 2020-06-01 at 9.36.29 AM](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/dedcdc0338ab3c13729c40b736f7c7497bb3c55f.png)

---

<div class="post-metadata">

**Author:** ![HeathClose](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/heathclose/32/1227_2.png) [@HeathClose](https://qa.fmod.com/u/HeathClose)\
**Post date:** [June 3, 2020, 9:17pm UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/2 "2020-06-03T21:17:35Z")

</div>

anyone know why this isn’t working?

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [June 4, 2020, 12:18am UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/3 "2020-06-04T00:18:08Z")

</div>

Could you please try unchecking the box that says “Allow Fadeout When”? It’s possible that there is something in the event preventing it from stopping immediately.

---

<div class="post-metadata">

**Author:** ![HeathClose](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/heathclose/32/1227_2.png) [@HeathClose](https://qa.fmod.com/u/HeathClose)\
**Post date:** [June 4, 2020, 2:58am UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/4 "2020-06-04T02:58:20Z")

</div>

thanks for the suggestion but unfortunately it didn’t work.

---

<div class="post-metadata">

**Author:** ![HeathClose](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/heathclose/32/1227_2.png) [@HeathClose](https://qa.fmod.com/u/HeathClose)\
**Post date:** [June 4, 2020, 3:09am UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/5 "2020-06-04T03:09:47Z")

</div>

I even tried to play it with code

```auto
public void AttachAudio(string eventToPlay)
        {
            fmodInstance = FMODUnity.RuntimeManager.CreateInstance(eventToPlay);
            FMODUnity.RuntimeManager.AttachInstanceToGameObject(fmodInstance, transform, rigidbody);
            fmodInstance.start();
            fmodInstance.release();
        }

```

in fact even if I put

`fmodInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);`

before the destroy, it doesn’t stop.

---

<div class="post-metadata">

**Author:** ![HeathClose](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/heathclose/32/1227_2.png) [@HeathClose](https://qa.fmod.com/u/HeathClose)\
**Post date:** [June 4, 2020, 3:32am UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/6 "2020-06-04T03:32:27Z")

</div>

I’ve even tried a double whammy in an OnDestroy() and it still doesn’t work…

```auto
private void OnDestroy()
        {
            if(attachFmodEvent)
            {
                fmodInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
                fmodInstance.setParameterByName(parameterOnDestroy, 1f, false);
            }
        }

```

parameterOnDestroy is a parameter which, at 1, turns the volume of the event all the way down… it still plays… I’m baffled

---

<div class="post-metadata">

**Author:** ![HeathClose](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/heathclose/32/1227_2.png) [@HeathClose](https://qa.fmod.com/u/HeathClose)\
**Post date:** [June 4, 2020, 1:34pm UTC](https://qa.fmod.com/t/stop-event-with-game-object-destroy/15833/7 "2020-06-04T13:34:47Z")

</div>

well… I feel stupid… and I’m sorry to have taken up so much of your energy for an error on my part…

after seeing that it wouldn’t destroy OR turn down… I realized there must be something wrong somewhere else… and the was another game object triggering the sound so that there were 2… one of them didn’t have a stop command… I’m sorry. Thank you for the help, just discussing it lead me to the answer eventually
