Hello!
So I’m trying to make an adaptive music section in my game, in a maze, where the farther the character goes in the maze the different sections of music play. I cannot figure out what I need to do for the life of me to get it to work.
I started with a Scott’s Game Sounds video:
Scott’s Game Sounds Method
I was following it very well and understanding everything up until 16:48, where he implements it through his own script. As far as I could tell, it’s some form of event trigger . I played around with the built in Unity one, but it didn’t play for me, even trying all the parameter types.
I tried that method on a cube/wall thing that is triggered when you pass through it. Then I tried using individual triggers, like the first cube you pass through changes the parameter to 1, and then the second wall turns off the first music and changes the parameter to 2. Moving between different triggers, the first one wouldn’t end when the second one started, I’m guessing because it’s technically playing the music two different times, and I just turned 1 off when 2 started. But I don’t understand how to do it with just one big trigger.
I kept this script from the first video to see if it would help:
public class FMODMusic : MonoBehaviour
{
private static FMOD.Studio.EventInstance Music;
// Start is called before the first frame update
void Start()
{
Music = FMODUnity.RuntimeManager.CreateInstance("event:/Music/ParameterBasedMusic");
//Music.start()
//Music.release();
}
// Update is called once per frame
public void Progress(float ProgressLevel)
{
Music.setParameterByName("Progress", ProgressLevel);
}
}
But I don’t understand, similarly, how to change the parameter seamlessly on a single script five different times (there are 5 locations).
Finally I found three videos(the link is one of them).
They are exactly what I need to do, just change the parameter in different area, but idk where to even start since all the other methods didn’t work, and one video offered a link where they learned it and the link was outdated but a little helpful where I made this script:
private static FMOD.Studio.EventInstance Music;
// Start is called before the first frame update
void Start()
{
Music = FMODUnity.RuntimeManager.CreateInstance("event:/Music/ParameterBasedMusic");
//Music.release();
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Intro")
{
Music.start();
Music.setParameterByName("Progress", 0f);
}
if (other.gameObject.tag == "Intro2")
{
Music.setParameterByName("Progress", 1f);
}
if (other.gameObject.tag == "First")
{
Music.setParameterByName("Progress", 2f);
}
if (other.gameObject.tag == "Second")
{
Music.setParameterByName("Progress", 3f);
}
}
But nothing happened so I tried a different approach, putting it on the triggers instead of the player character:
private static FMOD.Studio.EventInstance Music;
// Start is called before the first frame update
void Start()
{
Music = FMODUnity.RuntimeManager.CreateInstance("event:/Music/ParameterBasedMusic");
//Music.release();
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Body")
{
Music.start();
Music.setParameterByName("Progress", 0f);
}
}
All the scripts of a similar variety, just any after the first trigger didn’t have Music.start(). When I do that it plays the first time, but does not transition to any other regions.
So that’s everything I tried, I’m not sure where to go next. Thank you for your time, sorry for the long post.