Search Unity

Error that shouldn't be there?

Discussion in 'Scripting' started by BubyMB, Jan 9, 2017.

  1. BubyMB

    BubyMB

    Joined:
    Jun 6, 2016
    Posts:
    140
    http://pastebin.com/w3Zmweit : Health Bar script
    http://pastebin.com/rDHbiRzA: Health System script
    I was making an over head UI system, and ran across this error;
    'Null Reference Exception: object reference not set to an instance of an object HealthSystem.Update () (at Assets/Scripts/Player/HealthSystem.cs:24)'
    Now, Everything is working but it spits out that error every frame, as far as I know the script should be working fine. The error accoutns for both line 24 & 25
    --edit to clarify, both scripts are on the same object
     
    Last edited: Jan 9, 2017
  2. Dameon_

    Dameon_

    Joined:
    Apr 11, 2014
    Posts:
    542
    It's not finding your HealthBar component. My best guess, from the information given, is that you have your HealthSystem script on something that doesn't also have a HealthBar component. Since you say everything is working, I'd check your scene to see if there's an object that has a HealthSystem component with no HealthBar component.
     
    Polymorphik likes this.