Hi,
I have a radio in my game which should play a sound if I run against it. I finally wrote a script which doesn’t work. Because the point is: How can I get the radio to play a sound and NOT the first person controller?
Here’s the script so far:
function OnControllerColliderHit(hit:ControllerColliderHit) {
if(hit.gameObject.tag == “Radio”) {
sound_on();
}
}
function sound_on() {
var radio = gameObject.FindWithTag(“Radio”);
radio.audio.PlayOneShot(sound);
}
private var radio : GameObject;
function Start(){
//Store your tag into the private var
}
function OnControllerColliderHit(hit:ControllerColliderHit) {
if(hit.gameObject.tag == "Radio") {
radio.sound_on();
}
}