How to change snapshots in Unity C#


(Aleksi Sukava) #1

There is very little of information about this on the internet and the ones that i could find are old.

So how do you do it?

Right now im trying to run a script when you enter a collision box, the script is as follows:


using UnityEngine;
using System.Collections;
using FMOD;
using FMODUnity;

public class LaatikkoTesti : MonoBehaviour {

FMOD.Studio.EventInstance snapshot;
FMOD.Studio.EventDescription desc;
// Use this for initialization
void Start () {

}
	


// Update is called once per frame
	void Update () {
	
}

	void OnTriggerEnter (Collider other)
{

	{
		if (other.tag == "Player") {
			// TODO: include error checking
			FMODUnity.RuntimeManager.CreateInstance ("snapshot:/cave_reverb");
			desc.createInstance(out snapshot);
		}
	}
}

}


Please help!

PS. Eventhough FMOD is a wonderfull software, i find the resources for learning to be very limited and scattered.


(Cameron Baron) #2

Snapshots can be used the same way events are. Create an instance that you can play, pause and stop.

CreateInstance will return an instance using the string you pass it. From there you can call start and stop to use it. Don’t forget to attach it to the game object if needed.

snapshot = FMODUnity.RuntimeManager.CreateInstance (“snapshot:/cave_reverb”);
FMODUnity.RuntimeManager.AttachInstanceToGameObject(snapshot, Transform, Rigidbody);
snapshot.start();


(DAVID CLADERA) #3

Hi, using your post to make a question,

I understand that i can use the snapshot, like and instance, but, my snapshot, use 4 audio files, thaer are in 4 different events and in 4 independent groups, because the fmod not allow to agroups audiofiles or audiotracks, only events.

So, i want to mix this four tracks with differents volumes in my scene in differents ambients.

I have prepared the snapshots, and works (testing inside fmod).

My doubt is , how can i call the four events (with only one track for event) in unity for listen. I need to create four eventInstance, one for each event, and start alltogether? or there are some way to make it?

thanks for your response.


(Cameron Baron) #4

Yes each event will need to be played separately, then you can play the snapshot to effect those events.


(DAVID CLADERA) #5

OK, so i can use something like that to mix my music:

FMOD.Studio.EventInstance Strings;
FMOD.Studio.EventInstance Winds;
FMOD.Studio.EventInstance Brass;
FMOD.Studio.EventInstance Percussion;

Strings = FMODUnity.RuntimeManager.CreateInstance (“snapshot:/Music_Strings”);
Winds = FMODUnity.RuntimeManager.CreateInstance (“snapshot:/Music_Winds”);
Brass = FMODUnity.RuntimeManager.CreateInstance (“snapshot:/Music_Brass”);
Percussion = FMODUnity.RuntimeManager.CreateInstance (“snapshot:/Music_Percussion”);

snapshot = FMODUnity.RuntimeManager.CreateInstance (“snapshot:/Music_Night”);
FMODUnity.RuntimeManager.AttachInstanceToGameObject(snapshot, Transform, Rigidbody);
snapshot.start();

Strings.start();
Winds.start();
Brass.start();
Percussion();

Works??? the events start all at the same time syncro??

Thanks