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

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » FREE Project Downloads & Recources » Scripts » Audio in trigger

Audio in trigger

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Audio in trigger on Sat Aug 02, 2014 3:24 am

developer23


Moderator
Moderator
Hi guys! I created this very simple script. When the player go in a Trigger zone audio.Play and when the player exit audio.Stop.
Script (Js)
Code:
function OnTriggerEnter(){

audio.Play(); }

function OnTriggerExit(){

audio.Stop(); }

View user profile http://masterdevelopers.altervista.org/

2 Re: Audio in trigger on Sat Aug 02, 2014 4:22 am

developer23


Moderator
Moderator
I updated the script. After 4 seconds the object will it destroy.
SCript (Js)
Code:
function OnTriggerEnter(){

audio.Play(); }

function OnTriggerExit(){

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

View user profile http://masterdevelopers.altervista.org/

3 Re: Audio in trigger on Mon Aug 04, 2014 7:23 pm

Thanks for sharing and helping the community as usual!

View user profile http://www.youtube.com/user/misterninjaboy

4 Re: Audio in trigger on Tue Aug 05, 2014 2:01 am

developer23


Moderator
Moderator
MisterNinjaBoy wrote:Thanks for sharing and helping the community as usual!
Of nothing! Very Happy

View user profile http://masterdevelopers.altervista.org/

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum