# \[FMOD/Unity\] Cant stop event when function called

**URL:** https://qa.fmod.com/t/fmod-unity-cant-stop-event-when-function-called/13309
**Category:** Unity
**Created:** [July 24, 2017, 5:41pm UTC](https://qa.fmod.com/t/fmod-unity-cant-stop-event-when-function-called/13309 "2017-07-24T17:41:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![andypandy47](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@andypandy47](https://qa.fmod.com/u/andypandy47)
#### Post date: [July 24, 2017, 5:41pm UTC](https://qa.fmod.com/t/fmod-unity-cant-stop-event-when-function-called/13309/1 "2017-07-24T17:41:32Z")

</div>

Hi there,

Within one of my functions called when the mouse clicks a specific object in my game the function “pickup()” is called. The function should then stop the phoneRing event however it does not and seems to skip over it. I can stop the event in the “Update()” function by getting input from the mouse button however i was hoping to package it nicely within my other function. I cant see any reason as to why the event would be stopped just because its in a function that i have defined but perhaps theres something that im not aware of. Anyways heres the code

```
[FMODUnity.EventRef]
public string phoneRingEvent;
FMOD.Studio.EventInstance phoneRing;

float timeUntilFirstRing = 1.0f;

public GameObject gameController;

// Use this for initialization
void Start ()
{
    Hv_DTMF_Tones_AudioLib dialTones = GetComponent<Hv_DTMF_Tones_AudioLib>();

    phoneRing = FMODUnity.RuntimeManager.CreateInstance(phoneRingEvent);
    
}

private void Update()
{
   
    FMODUnity.RuntimeManager.AttachInstanceToGameObject(phoneRing, GetComponent<Transform>(), GetComponent<Rigidbody>());

    if (gameJustStart == true)
    {
        timeUntilFirstRing -= Time.deltaTime;
        if (timeUntilFirstRing <= 0)
        {

            Debug.Log("ring");
            
            phoneRing.start();
            gameJustStart = false;
            timeUntilFirstRing = 100000.0f;
        }
    }
    
}

public void pickup()
{
    phoneRing.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
    phoneRing.release();
    Debug.Log("stop");

}

```

stop is printed successfully to the debug window so the function is definitely being called, just not stopping the event.

Thanks!

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [July 25, 2017, 4:21am UTC](https://qa.fmod.com/t/fmod-unity-cant-stop-event-when-function-called/13309/2 "2017-07-25T04:21:11Z")

</div>

You can add some quick and easy debugging to any FMOD function by doing the following:  
`
FMOD.RESULT result = phoneRing.stop(FMOD.Studio.STOP_MODE_IMMEDIATE);
Debug.Log("Stop result = " + result);
`  
That should give you a bit more information on why it isn’t working.
