Set up 3rd listener on 3rd person camera and attenuation on character

Hi I wish to have panning info sent to my listener on the 3rd person camera and attenuation data being calculated based on the characters position. Is there a simple solution to this? I must stress that my C# implementation skills are quite basic so enhanced details would be appreciated.

Cheers

You will have to drive the listeners values manually to do this, instead of using a FMOD Studio Listener component.

  • You will need to make your own script that calls Studio::System::setListenerAttributes.
  • This function takes an FMOD.ATTRIBUTES_3D which is the same as FMOD_3D_ATTRIBUTES.
  • FMOD_3D_ATTRIBUTES has members for: position, velocity, forward and up. You can then drive those how ever you wish.

For example:

  GameObject player, camera;
  FMOD.ATTRIBUTES_3D attributes = new FMOD.ATTRIBUTES_3D();
  void Update()
  {
    attributes.position = FMODUnity.RuntimeUtils.ToFMODVector(player.transform.position);
    attributes.forward = FMODUnity.RuntimeUtils.ToFMODVector(camera.transform.forward);
    attributes.up = FMODUnity.RuntimeUtils.ToFMODVector(camera.transform.up);

    FMODUnity.RuntimeManager.StudioSystem.setListenerAttributes(0, attributes);
  }