Event stops before playing with loop and trigger zone. New bug?

Hello,

I encouter a problem while creating my interactive system for a game I work on. I use Fmod (2.01.09) and Unity (202.3.9). What I want to do is a music event played with a trigger zone activated with collider.

  • in unity : I created associated my event to a box collider and make it start when the player come across this zone. Also, I want that this event doesn’t stop while the player go out of the zone.
  • in Fmod : I set the max instance to 1 so the event cannot overlaping, and set stealing to “none”.

With this settings, my event should be activated while the player ome across the trigger zone, continue playing if the player come out of the zone and then, continue playing without any change if the player come again in the zone.

It works fine until I add a loop region in my event to make the music loop, or a marker at the start and a destination marker at the end of the music. In this case, when I enter again my zone, the event is stopped and then start again from the begining.

I don’t understand how adding a loop could create this problem. It’s like it changes my stealing settings.
Am I doing something wrong or is it a bug known for this version of Fmod ?

Thanks for your attention

Hi,
I don’t know how this could be related to adding a loop or a transition, that’s weird… But have you checked if when entering the collision box, a new event instance is always invoked? Because if not, if the already previously started instance is re-started instead, it’s normal that it restarts to the beginning, no matter how the stealing is set.

Hi, tank you to take a little time to answer !

How can I see if a new event instance is invoked or if it’s the previous one which is re-started ?
I don’t know why the event instance should restart form the begining as you said, because fmod shoul looks if there is already an instance of that event. If not, Fmod should launch a new instance. If yes, it shouldn’t start any new instance because an old one is already running.
I’m a bit disapointed bescause the problem doesn’t occurs when there is no loop region in my event.
Why a loop region should make Fmod re-start an event from the begining insteed continuing playing it whithout any changes ?

In Unity, I don’t know!

FMOD doesn’t look anything. You decide if you want to start another instance or restart an existing instance. But I don’t know how this is handled in Unity ; nor if it’s the problem…

Studio::EventInstance::start

Starts playback.

RESULT Studio.EventInstance.start();

If the instance was already playing then calling this function will restart the event.

I still think the problem should be there. Could you copy the code which you start the event with?

Unfortunately I don’t use code for the music system but the componnent in the unity’s inspector.

I guess the problem may be related to this EventInstance.start as you think. But a thing remains weird to me : why adding a loop region could restart the event ?
The code that you shared should restart the event in every case, with a loop region or not.

Ok, looking in the doc, I may have found your problem:

4.2.6 One Shot Sounds

If the Event is a one-shot then each call to Play from script or in response to a Unity event will spawn a new instance. Stopping will only stop the most recent instance. Looping events will restart if Play is called a second time without stopping.

If I understand that correctly, you should uncheck the “one shot” option, if available. You also maybe should take a look to the Trigger Once option, which seems to do what you want (removing the need for event steal setting).

According to the documentation, you can’t decide by yourself if an event is a one-shot event or not : “An event is considered oneshot if it is guaranteed to terminate without intervention in bounded time after being started”.
In my case, my music event is not a one-shot event because I added a loop region on it.
I don’t understand why this sente,ce Looping events will restart if Play is called a second time without stopping. is in the One Shot Sounds section so.

As I’m approaching to the answer, I feel that I need to discover how I can trigger an non one-shot event multiple times whithout restarting it.

Ok, then try to check the “persistent” button in the event macro settings. This option is meant to let the event alive, no matter what’s the content (even if empty) ; maybe this will make Unity consider the event is not “one shot” anymore.

That said, now that I reread the quote from the documentation, I realize it’s ambiguous: we don’t know if the “looping events” they are talking about are a particular category of “one shot” sound (as I understood the first time), or if it’s rather the opposite: looping events being by definition non one shot sounds. The second explanation makes more sense, in fact…

Did you try the “Trigger Once” option?

Yes that is the point, it sounds ambiguous for me to.
I’ve already thought about it, the trigger once option sovled the problem because the event is no more played after the first one. However, I need that my event could be triggered later after I’ll decide that my event has to stop. And that option doesn’t allow me to do that, untill the game componnent is destroy and reload (by changing the scene for example).

I see the point. From what I now understand, the fact that the event is looped makes it considered as non one-shot and so applies the behavior to restart a unique instance instead of starting another one. If that’s correct, there’s probably nothing you could do except coding yourself the logic of your collision box to trigger the FMOD event only when you want to.

I think I’ll have no other choice than coding myself the trigger script but it will be difficult as I’m completely new to the Fmod API.
It’s strange that Fmod doesn’t allow to make that in the software interface whithout coding with the API system. I thought that the interactive system that I’ve wanted to create won’t have been so complicated to make.

Thanks for your help

I rather had in mind to code the collision box in Unity so that it would only trigger the FMOD event once. It may be simpler to do that and keep FMOD on the native “high level”. Don’t you think so?

I’m not sure that it will work like that, because the behaviour of the event is described in Fmod.
I think that I’ll have the same problem if I only code the collision box.

If you program your collision box to only generate a collision once (or when you want), it will work.

I see. I will try that method and let you know if it will succeed.
Thank you

Hi there again. Sorry for the delay.

We finally fix the problem by coding the trigger condition.
The script check if the event is already playing before starting it.
I’m a bit disapointed that we needed to use some code to fix that but it’s ok, it works fine now.

Thanks for your help.