Skip to content

Instantly share code, notes, and snippets.

@OutlawGameTools
Created March 21, 2015 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OutlawGameTools/e3c46348078238e9ae88 to your computer and use it in GitHub Desktop.
Save OutlawGameTools/e3c46348078238e9ae88 to your computer and use it in GitHub Desktop.
CS109 - Add to a game object with Collider2D isTrigger to start music when triggered
#pragma strict
private var aSource : AudioSource;
function Start ()
{
aSource = GetComponent.<AudioSource>();
}
function OnTriggerEnter2D ()
{
if (!aSource.isPlaying)
aSource.Play();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment