Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

3d Platformer Tutorial GUI problems

Discussion in 'Immediate Mode GUI (IMGUI)' started by demetriusb, May 18, 2008.

  1. demetriusb

    demetriusb

    Joined:
    May 8, 2008
    Posts:
    4
    I'm trying the 3D Platformer Tutorial and am getting this error:

    NullReferenceException: Object reference not set to an instance of an object
    GameHUD.OnGUI () (at Assets/Scripts/GUI/GameHUD.js:40)

    How would one go about fixing this? Nothing displays when you run the game.
    Any help is appreciated.

    DemetriusB
     
  2. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Did you check what was on GameHUD.js line 40 that was looking for the null object, and make sure it's being instantiated correctly? Null Refs are usually caused by something simple.
     
  3. demetriusb

    demetriusb

    Joined:
    May 8, 2008
    Posts:
    4
    Here's the code from line 40. This isn't my code, but the code from the tutorial.

    var itemsLeft = playerInfo.GetRemainingItems(); // fetch items remaining -- the fuel cans. This can be a negative number!

    Any help is appreciated.

    Demetrius
     
  4. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Probably playerInfo is not instantiated or GetRemainingItems() is trying to access a null object. I haven't done the tutorial, so I don't know its inner workings.

    If you're not comfortable finding Null Refs, maybe you should try an easier tutorial than the 3D platformer to get comfortable first.
     
  5. demetriusb

    demetriusb

    Joined:
    May 8, 2008
    Posts:
    4
    I did the 2D tutorial, no problem. The First person tutorial, had way too many issues with the code. Struggling to get this working at this point. Even the 3D Platformer, had many issues, but I was able to solve many of them.

    If any body has done these tutorials and solved this issue, your help is appreciated.

    Demetrius
     
  6. demetriusb

    demetriusb

    Joined:
    May 8, 2008
    Posts:
    4
    I figured out my problem with the help of Tom at the Unity3D support staff. Thanks to everyone for their help.

    Demetrius
     
  7. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    As I recall when the 3D platformer tutorial was under development, Sean said that the intention was for the user to go through the entire tutorial and complete a fair number of scripting and IDE configuration tasks to make it work. It doesn't just work to build it out of the box.

    That means that the code isn't necessarily just plug and play without working through the tutorial to a significant extent.
     
  8. Mitendrius

    Mitendrius

    Joined:
    Oct 5, 2010
    Posts:
    6
    Can you tell us how to make it work? Cause i have the same problem too
     
  9. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    @Mitendrius: can you post the code that is causing this error and the line number quoted in the error message? This is a very general kind of error and the solution depends on the code you are using.
     
  10. tpelham

    tpelham

    Joined:
    Nov 15, 2010
    Posts:
    1
    Add the Third Person Status script to the LertzPrefab in the inspector. This script has the implementation of GetRemainingItems()

    This solved the problem for me. Perhaps the tutorial should be updated to add this set of steps.
     
  11. Dynamoo

    Dynamoo

    Joined:
    Oct 9, 2013
    Posts:
    1
    Thanks @tpelham