Advertisement
LittleAngel

Trigger Lights Off

Aug 30th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. private var soundPlayed : boolean = false;
  2. var audio : AudioClip; // Note change of capitalization of var name
  3. var volume: float = 10.45;
  4. var light : Light // Note change of capitalization of var name
  5.  
  6. function OnTriggerEnter(col : Collider){
  7. //Play Sound if player enters trigger
  8. if (!soundPlayed && audio) {
  9. // but only if it has not played before
  10. AudioSource.PlayClipAtPoint(audio, transform.position, 10.4);
  11. soundPlayed = true;
  12. // sound will not play anymore
  13. }
  14. light.enabled = false;
  15. }
  16.  
  17. You could also use:
  18. var lights : Light []; // which will use an array
  19.  
  20. and then use:
  21. for (var light : Light in lights) {
  22. light.enabled = false;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement