Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink
Share
Go down
avatar
Member [Lv. 2]
Member [Lv. 2]
Posts : 9
Points : 1356
Rep : 1
Join date : 2014-12-23
View user profilehttps://www.youtube.com/user/zinofxmovie/videos

sound trigger script

on Fri Dec 26, 2014 1:37 pm
Message reputation : 0% (1 vote)
hey gy this is sound trigger script enjoy


function OnTriggerEnter(){

audio.Play(); }

function OnTriggerExit(){

audio.Stop();
yield WaitForSeconds (4);
Destroy(gameObject);}
{SUPER MEMBER}-LV.4
{SUPER MEMBER}-LV.4
Posts : 60
Points : 1651
Rep : 3
Join date : 2014-04-29
Location : Algeria
View user profile

Re: sound trigger script

on Mon Jun 08, 2015 8:28 pm
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.
avatar
Moderator
Moderator
Posts : 329
Points : 2204
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: sound trigger script

on Thu Jun 11, 2015 3:10 pm
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
avatar
Moderator
Moderator
Posts : 329
Points : 2204
Rep : 43
Join date : 2014-03-12
Age : 18
Location : Italy
View user profilehttp://masterdevelopers.altervista.org/

Re: sound trigger script

on Thu Jun 11, 2015 3:11 pm
Why you copied me?? You put also the same time to destroy the object...
avatar
Member [Lv. 1]
Member [Lv. 1]
Posts : 2
Points : 1144
Rep : 0
Join date : 2015-07-07
Age : 22
Location : India
View user profile

Re: sound trigger script

on Tue Jul 07, 2015 6:44 am
dont fight its Nice Code ...... Very Happy
Back to top
Permissions in this forum:
You cannot reply to topics in this forum