Answered
0
0

hi folks, i perused the Unity threads and didn’t find what i’m looking for. i need a way to do the following:

play an event from a static 3D location by passing the location to the emitter. This is equivalent to AudioSource.PlayClipAtPoint(Vector3 location);

play an event from a moving 3D location by passing the game Object to the emitter. More like AudioSource.Play();

i do not want to put emitters on the source objects in the Hierarchy for this but would instead create objects with emitters in a dedicated scene for audio and would rather pass Vector 3 info to the Emitter if possible. alternately i could use the Studio Runtime Manager and pass position that way. i’m teaching FMOD and want to simplify the experience for them.

i looked into the Runtime Manager setup but it’s very confusing and seems to not work. here’s a quick example based on my understanding of how the Runtime Manager is called:

public void DartGunShoot(Vector3 location)
{
    var studioSystem = FMODUnity.RuntimeManager.StudioSystem;
    studioSystem.PlayOneShotAttached(dartGunShoot, location);
}

Mono Develop says that there is no method called PlayOneShotAttached and highlights it red.

dartGunShoot is the Event string and location is the passed Vector3. what am i doing wrong? i can’t call it by using public static void either. basically a C# example of this method in action would be fine. any help appreciated!

  • You must to post comments
Best Answer
1
0

PlayOneShotAttached is a function of the RuntimeManager, you can call it like this:

FMODUnity.RuntimeManager.PlayOneShotAttached(dartGunShoot, location);

The event will get added to a list and update with the gameObjects transform, you can use PlayOneShot() to fire an event that doesn’t update position.
Alternatively can use the StudioSystem to create and play an event and attach it to a gameObject so that you can still use the event reference.

FMODUnity.RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidbody);
  • You must to post comments
0
0

beautiful – thanks! my issue is not knowing how the definition of the function in the documentation differs from the application within the script. so trying to parse this, that public static void means you have to address it with the full namespace and method path, rather than say, getting an instance of it and then calling the function on the instance.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.