Пример #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("checkpoint"))
        {
            if (other.name == nextPointer.ToString())
            {
                // make sure counting is correct even if player moving backward or keep hitting the same checkpoint twice or more.

                checkPointsPassed++;
                nextPointer++;
                if (nextPointer == total)
                {
                    //current lap is finished
                    //reset the next pointer to 0
                    nextPointer = 0;
                }
                Debug.Log(gameObject.name + " passed checkpoints: " + checkPointsPassed);

                // call to rank racers
                RankingManager.RankingRacers();
            }
        }
    }