|
Post by isuckatcoding on May 23, 2021 16:29:04 GMT
Trying to add Master Sound Audio to an existing project and I suck at coding. I used the Master Sound tool to identify & remove all existing sound sources & now trying to add them back in. I'm using a 3rd party asset (Game Kit Controller) which has tons of scripts that also control various sound events.
My first test is trying to get a simple switch to also play a sound (switch is activated by pressing the E button on keyboard). I didn't see an option for this with the provided scripts, so I'm following the instructions on "Triggering Audio With Code". If there is a way to do this without code please let me know thanks.
I added the following to the top of the script: using DarkTonic.MasterAudio;
But when I add this line to the section where I want to trigger the sound I get errors for all the variables "the name 'volumePercentage' does not exist in the current context" for example.
MasterAudio.PlaySound3DAtTransform(string sType, Transform sourceTrans, float volumePercentage, float? pitch, float delaySoundTime, string variationName);
Do I need to create local variables for all these items?
ANY HELP WOULD BE APPRECIATED,
Thank you,
|
|
|
Post by DarkTonic Dev on May 23, 2021 19:21:15 GMT
You are correct, there is nothing built in for Keyboard triggering.
Those types such as "string", "float" in the PlaySound3DAtTransform call are to tell you what type you need to pass in, but you don't actually put the type in there. i.e. use a variable or constant of type "string" for "soundGroup" as shown below.
Your code could look like this:
[SoundGroup] public string soundGroup;
// inside your code to detect keypress, do this. MasterAudio.PlaySound3DAtTransform(soundGroup, this.transform);
The public soundGroup with the "SoundGroup" attribute (with square brackets around it) allows you to select your Sound Group in the Inspector from a dropdown.
-Brian
|
|
|
Post by isuckatcoding on May 23, 2021 21:31:39 GMT
Thank you for the quick response. I'll give that a shot.
|
|
|
Post by DarkTonic Dev on May 23, 2021 21:33:08 GMT
No problem.
|
|