- Home /
Sound play on key combinations?
I want to make it so when you press a type of keys, lets say for example you type "MAU" and it will make a sound play. The only thing I've been able to do is make a sound play when you press a certain button, but not more than one.
I guess what you are doing now is just something like this:
if (Input.Get$$anonymous$$eyDown("$$anonymous$$"))
audio.Play();
}
What I think might be a solution is ins$$anonymous$$d of playing the sound, add the sound to a List (for instance ArrayList). And when you are done pressing a combinaton it can loop trough the list to check what the combination are and then play the correct sound. How to initiate the loop might by pressing a key or maybe have a timer check if no key is pressed the last 5 seconds or something.
Hope this answear gave you some ideas! Good luck! :)
Answer by IgorAherne · Jul 21, 2013 at 09:18 AM
Using this:
http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use?#Hashtables
Read about hash tables.
After that, you would want to store strings as keys, and for values store a audio.Play("your MAU track");
Your answer

Follow this Question
Related Questions
Sound to play when clicking buttons on GUI 1 Answer
What Am I doing wrong? 1 Answer
Background music and button sound at the same time PROBLEM 1 Answer
How To play sound with a keypress 2 Answers