Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pringithub/7a9b8bf0caf94dcc11208c21e5bc2a9f to your computer and use it in GitHub Desktop.
Save pringithub/7a9b8bf0caf94dcc11208c21e5bc2a9f to your computer and use it in GitHub Desktop.
Press the blue button to instantiate cubes, press the red button to destroy them.
// Game object "index" refers to the LeapMotion index finger
private void OnTriggerEnter(Collider c)
{
if (this.name == "blue")
{
if (c.gameObject.transform.parent.name.Equals("index") && numPrefabs < MAX_NUM_PREFABS)
{
prefabs[numPrefabs] = Instantiate(prefab) as GameObject;
numPrefabs += 1;
}
}
if (this.name == "red")
{
for (int i = 0; i < MAX_NUM_PREFABS; i++)
{
Destroy(prefabs[i]);
}
numPrefabs = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment