var crashSound : AudioClip;
var otherObject : GameObject;
var soundplayed = false;
function Update(){
print ("Scary Noise");
if (otherObject.renderer.isVisible)
{
if(soundplayed==false) { Debug.LogWarning("Test sound"); otherObject.audio.PlayOneShot(crashSound); soundplayed = true;
}
}
if (otherObject.renderer.isnotVisible)
{
soundplayed = false;
}
}
that code does’nt seem to want to work. what im trying to do is if otherObject is in view play sound. and if not. do nothing lol. seems to not want to work. a little help?
if (otherObject.renderer.isnotVisible)
What is ‘isnotVisible’? Does that compile?
Should it not be:
if (otherObject.renderer.isVisible == false)
Hi,
Maybe the otherObject GameObject has no “Audio Source” (or his volume is set to 0) or maybe the Camera Object has no “Audio Listener” (or it’s deactivated)? Maybe you muted your computer’s speakers ? (sounds obvious but it already happened to me…).