|
Post by IcyHot on May 6, 2020 8:55:21 GMT
I may have missed something in the videos and tutorials but I can only find a function for mouseclicks to trigger audio.
Is there any way to have a keypress trigger audio as well?
I have a script running off code of if (Input.GetKeyDown(KeyCode.Y)) and can't seem to find a way to link the audio script and the custom script running my action. Any ideas?
|
|
|
Post by DarkTonic Dev on May 6, 2020 15:08:07 GMT
Correct, I never coded keypress. Believe it or not, no one has ever asked for in over 8 years.
You'll need to do that one yourself.
You can insert code like this into your script.
MasterAudio.PlaySound3DFollowTransformAndForget("SoundGroupName", this.transform);
Thanks, -Brian
|
|
|
Post by IcyHot on May 6, 2020 20:14:12 GMT
Interesting, I’ll try it when I get back. Would that be all the code needed to insert into my script to say play a soundgroup on the player or other source every time I press that key? Just bought the asset and trying to still get familiar with it. Thanks.
|
|
|
Post by DarkTonic Dev on May 6, 2020 20:16:07 GMT
Yeah, it's always a 1-liner to play a Sound Group at whatever time.
|
|
|
Post by IcyHot on May 7, 2020 5:02:05 GMT
Wow that was really easy actually.
I only have one issue with this solution. It is attached to an object with the script and as such playing the audio on that object which can move away from the player. Is there a way to make this play just on the player?
|
|
|
Post by IcyHot on May 7, 2020 6:49:14 GMT
I believe I found my own answer. I simply added similar code to a player script as well as the object and used different sound groups for each using a delay to facilitate a command - response type sound usage.
|
|
|
Post by DarkTonic Dev on May 7, 2020 15:09:03 GMT
Awesome. If it is the same sounds you want to play on both, you don't need separate Sound Groups. 1 will do any number of "actors".
|
|