Advertisemen
Unity 3D Play Audio Sound OnTriggerEnter
Making free platform game ! One man show
----------------------------------------
Javascrip: GOOD 4 2D GAMES AND 3D GAMES !
----------------------------------------
var soundFile:AudioClip;
function OnTriggerEnter(trigger:Collider) { if(trigger.collider.tag=="Player&qu
}
---------------------------------------------------------------
Dear members here is alternatives !
All Java Scripts name it how you like !
------------------------------------------------------------------------------------
First Java script is for looping music after trigger enter :
------------------------------------------------------------------------------------
All Java Scripts name it how you like !
------------------------------------------------------------------------------------
First Java script is for looping music after trigger enter :
------------------------------------------------------------------------------------
var Sound :AudioClip;
function OnTriggerEnter() {
audio.clip = Sound;
audio.Play();
}
function OnTriggerExit(){
audio.Stop();
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
Second Java script is for sounds to fire only once:
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
private var hasPlayed : boolean = false;
var Sound : AudioClip;
function OnTriggerEnter() {
if(!hasPlayed){
audio.clip = Sound;
audio.Play();
hasPlayed = true;
}
}
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Third Java script is for trigger sounds (fire every time you enter a trigger):
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
var Sound : AudioClip;
function OnTriggerEnter() {
audio.clip = Sound;
audio.Play();
}
made with ezvid, free download at http://ezvid.com
Advertisemen
Tidak ada komentar:
Posting Komentar