private void OnTriggerEnter(Collider other) { if (other.tag == obstacleTag) { //run related script to handle player lives livesSystem.subtractLives(); //analytics int stageNumber = sceneManager.GetStageNumber(); int levelNumber = sceneManager.GetLevelNumber(); Vector3 playerPosition = this.transform.position; analyticsTracker.OnPlayerHitsObstacle(other.name, stageNumber, levelNumber, playerPosition); //play animations involved animations.PlayerGetsHit(); //script accesses the object and runs the script associated with despawning it Destroy(other.gameObject); } if (other.tag == passTag) { //run related script to handle hall passes obtained hallPassSystem.AddHallPass(); //script accesses the object and runs the script associated with despawning it fade = other.gameObject.GetComponent <fadeOut_CS>(); fade.SetBool(true); other.enabled = false; //call related UI and Particle Animations here } if (other.tag == finishLineTag) { //tells the game that the level is finished mainGameplayUI.SetBool(true); //play animations involved } if (other.tag == customItemTag) { // call related UI and Particle Animations here Debug.Log("You've obtained a HAT! Got to the customize menu to see how it looks on you."); hatAnimation = other.gameObject.GetComponent <hatAnimation_CS>(); hatAnimation.AddHat(); //script accesses the object and runs the script associated with despawning it fade = other.gameObject.GetComponent <fadeOut_CS>(); fade.SetBool(true); fade.SetPromptActive(); } }