3 times fell - you're dead

How can make a cube that fell of the platform and reached Y - 80 3 times and make it disappear off the scene (get destroyed).

  • Felipe
  1. On your cube, add a new script.

  2. Let that script have a counter for the number of times you have fallen off the platform.

  3. Give the script a reference to your current platform (and don’t forget to update that regularly).

  4. Now, test for the player’s position relative to the platform and increment your conter: “if (platform.transform.position.y - this.transform.position.y > 80) { fallCount = fallCount +1 }”.

  5. Finally: Test if your fall-counter is 3 and then destroy the gameobject: “if (fallCount == 3) { GameObject.Destroy (this.gameObject); }”