UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


descriptionsound trigger script  Emptysound trigger script

more_horiz
hey gy this is sound trigger script enjoy


function OnTriggerEnter(){

audio.Play(); }

function OnTriggerExit(){

audio.Stop();
yield WaitForSeconds (4);
Destroy(gameObject);}

descriptionsound trigger script  EmptyRe: sound trigger script

more_horiz
This code is perfect for a jump scare because it plays the audio once only.

Also note that the number 4 in yield WaitForSeconds (4); is the length of the audio file.

descriptionsound trigger script  EmptyRe: sound trigger script

more_horiz
I already posted the same script:

Code:

function OnTriggerEnter(){

audio.Play(); }

function OnTriggerExit(){

audio.Stop();
yield WaitForSeconds (4);
Destroy(gameObject);}


Last edited by developer23 on Thu Jun 11, 2015 3:12 pm; edited 1 time in total

descriptionsound trigger script  EmptyRe: sound trigger script

more_horiz
Why you copied me?? You put also the same time to destroy the object...

descriptionsound trigger script  EmptyRe: sound trigger script

more_horiz
dont fight its Nice Code ...... Very Happy

descriptionsound trigger script  EmptyRe: sound trigger script

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply