I’m doing a little project at home to try and learn how to use unity and fmod. I’m having some difficulty finding a working example of what i’d like to do.

Basically i want to simply trigger a sound from a game object which exists in my level.

So far i’ve not really found anything that seems to be up to date, so i thought i’d ask on here :) I’m running unity 5.4 and fmod studio 1.08.09

I have a script i got from unity asset manager which handles the timing of playing the foot step samples fine, along with camera behaviour. It had some foot step audio triggers in there already which worked ok but it was just using the unity audio engine but i would like to learn how to use the fmod engine :)

The script i got essentially added an audio source to the fps controller and used that to define the world position.

It seems that you can’t really use studio event emitters in the same way. As falloff attenuation etc is handled within the event in fmod, it’s not as nessercary within fmod anyway.

My play sound script section for fmod is quite simple, as follows:

FSev = FMODUnity.RuntimeManager.CreateInstance(Footsteps);

At the top all i’m doing is declaring the event and there is nothing about world position.

When i run the game i get a message along the lines of you need to set 3d attributes as your sound is playing at world 0.

I’ve had a good old guess at what the syntax might be but i’m basically not sure what arguments i need, any declarations of objects from unity i need, how that would all get tied together in a unity script.

Any help anyone can provide would be greatly appreciated.


  • You must to post comments
Best Answer

If your footstep event is continuous I would use

FMODUnity.RuntimeManager.AttachInstanceToGameObject(FSev,  GetComponent<Transform>(), GetComponent<Rigidbody>());

this example also has what you’re after

  • ben wolland

    hi! thanks for that it sent me down the correct path. :) i’ve ended up using FSev.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, playerPos)); to set the 3d position each time a foot step is played. Which seems to work. Not sure if it’s best practise or not but setting it each time the sound is played is probably the most effecient solution?

  • ben wolland

    to further explain where i was going wrong in case anyone else gets stuck where i was. I didn’t understand how you used (gameObject, TheObjectNameYouDeclaredIt) so i was thinking i had to replace the word gameObject with the name. I also didn’t understand the use of Rigidbody whateveriwanttocallit; and then the need to use get component so i can then use rigidbody for my purposes.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.