Skip to content

Instantly share code, notes, and snippets.

@benmcnelly
Created October 31, 2013 22:56
Show Gist options
  • Select an option

  • Save benmcnelly/7258571 to your computer and use it in GitHub Desktop.

Select an option

Save benmcnelly/7258571 to your computer and use it in GitHub Desktop.
Get the key...
// set some variables to use later
var keys = 0;
//Get THEKEY
function OnTriggerEnter(theCollision : Collider){
if(theCollision.gameObject.name == "THEKEY"){
keys+=1;
Debug.Log(keys);
Debug.Log("YAY YOU GOT THE KEY");
UnityEngine.Object.Destroy(GameObject.Find("THEKEY"));
}
if(theCollision.gameObject.name == "THEDOOR"){
if(keys == 1){
Debug.Log("Open Door");
UnityEngine.Object.Destroy(GameObject.Find("THEACTUALDOOR"));
UnityEngine.Object.Destroy(GameObject.Find("THEDOOR"));
keys-=1;
Debug.Log(keys);
}
else {
Debug.Log("NEED KEY FOOL");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment