private void OnTriggerEnter(Collider target) { if (target.tag == "Boost") { boostDuration = initialBoostDuration; isBoosting = true; } checkpointTrigger pos = target.GetComponent <checkpointTrigger>(); if (pos != null) { if (pos.position > currentCheckpoint && pos.position < currentCheckpoint + 2) { currentCheckpoint = pos.position; Debug.Log("Hit " + pos.position); Debug.Log("You are now " + currentCheckpoint); } else if (currentCheckpoint == 5 && pos.position == 0) { Debug.Log("Hit " + pos.position); Debug.Log("Lapped!"); currentLap += 1; currentCheckpoint = pos.position; } } }
private void OnTriggerEnter(Collider target) { if (target.tag == "Boost") { boostDuration = initialBoostDuration; isBoosting = true; } checkpointTrigger pos = target.GetComponent <checkpointTrigger>(); if (pos != null) { if (pos.position > currentCheckpoint && pos.position < currentCheckpoint + 2) { currentCheckpoint = pos.position; Debug.Log("Hit " + pos.position); Debug.Log("You are now " + currentCheckpoint); } else if (currentCheckpoint == 5 && pos.position == 0) { Debug.Log("Hit " + pos.position); Debug.Log("Lapped!"); currentLap += 1; currentCheckpoint = pos.position; LapText.text = ("Lap: " + currentLap.ToString() + " / " + maxLap.ToString()); if (currentLap > maxLap && !playerWon) { LapText.text = (" "); WinText.text = ("Player " + playerNumber + " Wins!"); playerWon = true; } } } }