Exemplo n.º 1
0
    private void RespawnInRace()
    {
        CheckpointCheck lastChecked = startCheckpoint.FindLastChecked();

        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("MainPlayer");
        }
        if (lastChecked)
        {
            player.transform.position = lastChecked.transform.position + Vector3.up * 2f;
            player.transform.rotation = lastChecked.GetRotationTowardsNext();
            player.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            player.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
        }
    }
    public CheckpointCheck FindLastChecked()
    {
        if (!isChecked)
        {
            return(null);
        }

        if (nextCheckpoint == null)
        {
            return(this);
        }

        if (nextCheckpoint.isChecked)
        {
            return(nextCheckpoint.FindLastChecked());
        }

        return(this);
    }