0
0

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!

  • You must to post comments
0
0

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.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.