コード例 #1
0
    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;
            }
        }
    }
コード例 #2
0
ファイル: PlayerManager.cs プロジェクト: MDiaz581/Project2
    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;
                }
            }
        }
    }