Search Unity

Where should ammunition on the GUI be handled?

Discussion in 'Getting Started' started by warrenbrandt, Jul 25, 2019.

  1. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413
    I have a turret shooting bullets
    i have a script called shoottomouse that handles that
    i can currently set how many bullets the player has and the gun is clicking when hes out

    i want to display the amount of bullets the player has

    i created a text box in the unity editor and called it ammoCount

    then in my shooting script i did
    public Text ammunitionCount;

    in my voidUpdate() i did
    ammunitionCount.text = ammunition.ToString();

    but its not shooting at all now and im getting an error
    NullReferenceException: Object reference not set to instance of an object

    anyhelp/advice appreciated
     
  2. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413