Reference Issues Within the Photon Tutorial

Options
I've recently gone through the PUN tutorial and have been attempting to remedy any errors that have been plaguing me. However, one remains that I feel like has a simple solution that is starting me in the face; I'm running into a null reference error within the PlayerUI section of code. To keep it short, anytime I click the Leave button, or a player hits 0 HP, the error presents itself, and points to the Update function that's within the MonoBehaviour CallBacks region. Specifically, the line under if(playerHealthSlider != null). It contains the following segment; playerHealthSlider.value = target.Health. Does it have something to do with target? Any help would be appreciated!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Rundas,

    Thank you for choosing Photon!

    Add a check:
    if (playerHealthSlider != null && target != null) 
    {
         playerHealthSlider.value = target.Health
    }