/// When player object contacts with an object void OnCollisionEnter(Collision collision) { //Gameover when touches the ground if (collision.transform.tag == "Arch" && mode != "GAMEOVER") { soundEffectController.playHit(); if (mode == "LEFT") { GameOverDriftDirection = "LEFT"; } else if (mode == "RIGHT") { GameOverDriftDirection = "RIGHT"; } //Control FX offDriftFX(); previousMode = mode; mode = "GAMEOVER"; gameOverReason = "HIT GROUND"; } //Shake camera when player hit's small road object if (collision.transform.tag == "Small Road Object") { cameraController.startLightShake(); soundEffectController.playKnock(); } if (collision.transform.tag == "Coins") { scoreController.addCoins(); collision.transform.parent.gameObject.SetActive(false); soundEffectController.playCoins(); } //Gameover when touches the ground if (collision.transform.name == "Ground" && mode != "GAMEOVER") { soundEffectController.playHit(); if (mode == "LEFT") { GameOverDriftDirection = "LEFT"; } else if (mode == "RIGHT") { GameOverDriftDirection = "RIGHT"; } //Control FX offDriftFX(); previousMode = mode; mode = "GAMEOVER"; gameOverReason = "HIT GROUND"; } //When car hits Lane Collider // reposition car if (collision.transform.tag == "Lane Collider") { //reposition car //transform.position = new Vector3(collision.transform.position.x, transform.position.y, transform.position.z); laneAdjustmentRequire = true; laneAdjustment_x = collision.transform.position.x; //Remove the lane collider collision.gameObject.transform.parent.gameObject.SetActive(false); if (collision.transform.name == "Lane Collider L") { onLaneNumber = -1; } if (collision.transform.name == "Lane Collider M") { onLaneNumber = 0; } if (collision.transform.name == "Lane Collider R") { onLaneNumber = 1; } } }