private void Start()
        {
            // Find the UI in the scene and store a reference for later use
            ui = GameObject.FindObjectOfType <UIScript>();

            // Set the player number based on the GameObject tag
            switch (gameObject.tag)
            {
            case "Player":
                playerNumber = 0;
                break;

            case "Player2":
                playerNumber = 1;
                break;

            default:
                playerNumber = -1;
                break;
            }

            // Notify the UI so it will show the right initial amount
            if (ui != null &&
                playerNumber != -1)
            {
                ui.SetHealth(health, playerNumber);
            }

            maxHealth = health; //note down the maximum health to avoid going over it when the player gets healed
        }
Ejemplo n.º 2
0
 // Start is called at the beginning
 private void Start()
 {
     // Find the UI in the scene and store a reference for later use
     userInterface = GameObject.FindObjectOfType <UIScript>();
 }