FMOD integration how to check if audio finished

Announcements, support questions, and discussion for the Dialogue System.
Saper
Posts: 85
Joined: Tue Jan 12, 2021 11:25 am

FMOD integration how to check if audio finished

Post by Saper »

Hi Tony

I want to check if audio was finished. To play audio i use sequence: FMODWait(AudioName, EventProgramerIntrument);
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: FMOD integration how to check if audio finished

Post by Tony Li »

Hi,

You can use regular sequencer messages. For example, to play two FMOD events one after the other:

Code: Select all

FMODWait(firstEvent)->Message(FirstDone);
FMODWait(secondEvent)@Message(FirstDone)
Or to activate GameObject when the FMOD event is done:

Code: Select all

FMODWait(firstEvent)->Message(Done);
SetActive(SomeGameObject)@Message(Done)
Saper
Posts: 85
Joined: Tue Jan 12, 2021 11:25 am

Re: FMOD integration how to check if audio finished

Post by Saper »

Hi Tony

Is there a posibility to setup something outside dialogue system outside SetActive object?
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: FMOD integration how to check if audio finished

Post by Tony Li »

Sure, you can do anything. That was just an example to demonstrate how to know when FMODWait() is done. What do you want to do?
Saper
Posts: 85
Joined: Tue Jan 12, 2021 11:25 am

Re: FMOD integration how to check if audio finished

Post by Saper »

Hi Tony

I want to change variable in one of ours classes
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: FMOD integration how to check if audio finished

Post by Tony Li »

Hi,

If you write a C# method to access your variables, you can register it with Lua to call that method in your conversations.

More info: How To: Connect C# Variables to Dialogue System's Lua
Saper
Posts: 85
Joined: Tue Jan 12, 2021 11:25 am

Re: FMOD integration how to check if audio finished

Post by Saper »

After I register my metod, sequence should looks like this?:

Code: Select all

FMODWait(firstEvent)->Message(Done);
MyMetod() @Message(Done)
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: FMOD integration how to check if audio finished

Post by Tony Li »

Hi,

If you want to change a variable from within a sequence, don't register your C# method with Lua. (In other words, don't use the instructions I provided in the link above.) Instead, write a custom sequencer command.

Use Lua functions in Conditions and Script fields. Use sequencer commands in Sequence fields.

Example sequencer command:

Code: Select all

public class SequencerCommandMyMethod : SequencerCommand
{
    void Awake()
    {
        MyClass.Instance.Variable = GetParameterAsInt(0);
        Stop();
    }
}
Example use:

Code: Select all

FMODWait(firstEvent)->Message(Done);
MyMethod(42)@Message(Done)
Saper
Posts: 85
Joined: Tue Jan 12, 2021 11:25 am

Re: FMOD integration how to check if audio finished

Post by Saper »

Hi Tony

Our class is on object, and before the FMOD we used "OnSequenceEnd" for check "if audio finished", with FMOD this don't work by using "OnSequenceEnd" it almost at start set the var to true
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: FMOD integration how to check if audio finished

Post by Tony Li »

Hi,

If the sequence uses FMODWait(), it should wait until the FMOD event is done before sending the OnSequenceEnd message.

Maybe some other sequence (e.g., some other dialogue entry) is sending OnSequenceEnd.

Can you use the "->Message(Done)" syntax I suggested above?
Post Reply