Pausing Music and Resuming from Same Location?


(kristi knupp) #1

Hi everyone!

I have a question regarding music integration. I’m hoping someone can help.

In this game I’m working on we have music that is triggered in the main level, but when a player enters a building that music stops until the player exits the building.

Upon exiting the building the music comes back on but always starts at the beginning of the piece.

Is it possible in F-MOD to set it up so that when exiting a building the music resumes from where it left off before the player entered the building?

Thanks,
Kristi


(Cameron Baron) #2

It sounds like you might be calling Play on the sound to resume it after the pause.
Calling play on an event will start it from the beginning, you need to use setPaused(false) to resume a paused event.

https://fmod.com/resources/documentation-api?page=content/generated/FMOD_Studio_EventInstance_SetPaused.html#/


(kristi knupp) #3

Thank you Cameron. Is this something on the code side? So I need to set my event up in F-Mod Studio any differently? I just have an event set to looping, nothing fancy.


(Cameron Baron) #4

Just the code, you don’t need to change the event at all.

Use EventInstance.setPaused(true) to pause.
And EventInstance.setPaused(false) to resume.


(kristi knupp) #5

Awesome thanks!