i don't understand why sound trigger not working. have created gameobject , added audio source (on audio source have play on wake , loop checked. added sphere collider (i have is trigger checked). added script , added sound clips inspector. unity says that: "there 2 audio listeners in scene." have pretty unchecked audio listeners , still says it, doing wrong?
here @ code:
#pragma strict var walkaudio:audioclip; var outcry:audioclip; function update (){ var audio= gameobject.getcomponent(audiosource); if(input.getbutton("horizontal") || input.getbutton("vertical")) { audio.play(); } else { audio.pause(); } } function oncontrollercolliderhit (hit : controllercolliderhit) { var audio= gameobject.getcomponent(audiosource); if (hit.gameobject.tag == "templefloor") { var groundtype = 1; print("temple"); audio.clip=outcry; } else{ audio.clip=walkaudio; } }
as said:
i have pretty unchecked audio listeners
the component audiolistener attached main camera must enabled. have used loadleveladditive have 2 camera , 2 audiolistener components, 1 on each of them. please make sure additive camera , other gameobject should have component disabled.
also at runtime, can search component(s) have audiolistener component attached using in hierarchy window search bar.
t:audiolistener this should out. double check using debug.log oncontrollercolliderhit function calls , audio.clip not null after assignment. necessary play sound in update ?
also, should move line update start function instead, due performance cost:
var audio= gameobject.getcomponent(audiosource); and use audio variable throughout script.
Comments
Post a Comment