Skip to content

Instantly share code, notes, and snippets.

@OutlawGameTools
Created March 21, 2015 05:06
Show Gist options
  • Save OutlawGameTools/e34e5a26a3f05693af1c to your computer and use it in GitHub Desktop.
Save OutlawGameTools/e34e5a26a3f05693af1c to your computer and use it in GitHub Desktop.
CS109 - Starts an AudioSource playing when attached object collider2D is 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