Hi
how do i play a sound if i press a particular key
(sorry to ask a stupid question but i find it hard to do the programming)
regards
Bruno
Hi
how do i play a sound if i press a particular key
(sorry to ask a stupid question but i find it hard to do the programming)
regards
Bruno
Here he is again! I made a custom script with a brunoSound variable !!! ... attach this javascript script to an object, add an audio source and then add a sound file in the inspector next to the variable brunoSound.
var brunoSound : AudioClip;
function Update() {
if (Input.GetButtonDown("Fire1")
{
audio.PlayOneShot(brunoSound);
}
}
@script RequireComponent(AudioSource)
It is easy:
if (Input.GetKeyDown("s"))
{
audio.Play();
}