Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        // Declare variables
        Player      playerScript      = FindObjectOfType <Player>();
        Respawn     respawnScript     = FindObjectOfType <Respawn>();
        LiveDisplay liveDisplayScript = FindObjectOfType <LiveDisplay>();

        if (playerScript != null)
        {
            if (playerScript.Live > 0)
            {
                playerScript.Live--;

                if (respawnScript != null)
                {
                    respawnScript.StartPosition();
                }

                if (liveDisplayScript != null)
                {
                    liveDisplayScript.SetHearts();
                }
            }
            else
            {
                SceneManager.LoadScene(3); // Load lose screen
            }
        }
    }
Пример #2
0
    void ResetPlayerPosition()
    {
        if (transform.position.y < resetPoint)
        {
            respawnScript = FindObjectOfType <Respawn>();

            respawnScript.StartPosition();
        }
    }