Hi, people! I have been playing around with FMOD and Unity for some time now, and I am a bit stuck. I have a sound that I want to be played whenever the player moves. I achieved this with Unity’s AudioSource, but I want to change it to using FMOD components now.
I had this code before:
void PlayStep(AudioSource step) {
if (step.time > 2.4 || !step.isPlaying)
step.Play();
}
After an intense googling session, it now looks like this:
void PlayStep(FMOD.Studio.EventInstance step, FMOD.Studio.PLAYBACK_STATE playState) {
step.setVolume(1f);
if (playState != FMOD.Studio.PLAYBACK_STATE.PLAYING) {
print(FMOD.Studio.PLAYBACK_STATE.PLAYING);
step.start();
}
}
The print shows ‘PLAYING’ all the time, yet nothing can be heard.
The sound is in a Control.cs script, which is attached to the Player. I also have a background track as another component (which might be the reason I get ‘PLAYING’). (Edit: I tried removing the track, but I still get ‘PLAYING’). However, I am still not sure how to attach an FMOD audio, be it an instance or an event emitter as a component, which could be what is causing the problem too…
Any clues and help is much appreciated. Thanks a lot!
EDIT: Turns out the code was functioning, but the player was away from where the Event was played from - (0,0,0). I have posted a slightly more detailed explanation (and, of course, all the issues that followed) here: http://www.fmod.org/questions/question/attach-fmod-event-to-a-gameobject-unity/ . I thought it’s wort keeping the thread in case someone runs into a similar problem