Announcement

Collapse
No announcement yet.

Variable not correctly showing in HUD - Please help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Variable not correctly showing in HUD - Please help!

    I have a pawn (Spaceship) that moves. It has an int variable (FuelAmount). When the pawn moves the variable reduces.

    I need the variable to display on the HUD. My HUD and widget are set-up and the default variable value display however it does not change when triggered.

    The variable seems to be coming from somewhere else, a duplicate of spaceship that is not in the scene.

    Even weirder, I tested the FuelAmount variable by using keypress events (1 & 2) to increase or decrease the variable. When I do this the HUD does change AND a new instance of SpaceShip appears from no-where!

    IWhat could I be doing wrong? I'm guessing the function / casting / getting within the Hud's binding function is wrong?

    Any help or guidance is much appreciated. I've been banging my head against the wall for week over this one

    Images attached.

    #2
    what have you got callin your custom event. Everything else looks right. Ive been doing this a lot recently so perhaps I can help you.
    Last edited by viggerz; 09-24-2017, 08:05 AM.

    Comment


      #3
      Thanks Viggerz, so the custom event is MoveSpaceShip and it's triggered when you click on a separate actor (a floor tile).

      The weird thing is that I've included a print function on the custom events that display the variable and it works fine but not on the hud display. The hud variable only changes if triggered with the key press... but it's exactly the same blueprint as the custom event!

      I'm so confused!
      Last edited by fandangoflip; 09-24-2017, 08:26 AM.

      Comment


        #4
        Yea I can see why. That's actually imppossible. The only reason I can see why it wouldn't work it because the custom event isn't even being called. Although you say the string prints. It wouldn't print if it wasn't called. Looks like you could have a bug now.

        Could it be where your calling your update fuel function? Although it still wouldn't change then even with key press...
        Last edited by viggerz; 09-24-2017, 08:35 AM.

        Comment


          #5
          I just noticed that this error is only occuring if I go to World Settings and select the default Pawn Class to be my spaceship. If I leave it empty it won't display anything in the hud variable area BUT the print function still works correctly.

          Any ideas how I can reference the variable of an instance only? EG, the instance of the ship I placed in my game?

          Comment


            #6
            I had this happen before, Double Layering of text with my score counter, causing a mess on the screen and there was no second text box
            causing it or any blueprint code putting an extra layer of the score counter text.. But I think this system dosen't always delete things properly after each compile and leaves traces of old deleted data behind if you fiddle too much around tweaking the nodes all the time.. For some reason the engine has trouble updating its nodes.

            Got a problem I also need resolving.

            i go into my widget delete the canvas panel and then insert a size box and then soon as I try to resize my size box, under the panel Child Layout the size box refuses to update itself on my screen but stays the same size no matter what height or width numbers I insert into the Override fields for the Height and Width...

            The Green box will not resize itself. i also tried CUSTOM SCREEN SIZE, I can now resize the screen, but cannot adjust the size box. HELP, what do I do to get the size box to resize itself? I don't know how to do it through the blueprint nodes, I only know how to try to resize the size box through using the Widget Designer panel. And because I want to put the skill tree system in my game, I can't make the widgets for the skill tree because the size box override is not resizing it.

            I am using 4.16





            Last edited by tozan; 09-26-2017, 02:57 AM.

            Comment


              #7
              Originally posted by alexjshelley View Post
              I just noticed that this error is only occuring if I go to World Settings and select the default Pawn Class to be my spaceship. If I leave it empty it won't display anything in the hud variable area BUT the print function still works correctly.

              Any ideas how I can reference the variable of an instance only? EG, the instance of the ship I placed in my game?
              In your HUD function Update Fuel, you are getting the fuel value from the "Player Pawn". But it sounds like the SpaceShip instance you're actually using in your game is one you've manually added or spawned in to the world, i.e. it's not the not the default one the game spawns for you and possessed by your Player Controller. So the ship you're moving around is not the same ship the HUD is reading from (and so have different copies of the Fuel variable)

              If that's the case, if you set your SpaceShip as the default Pawn Class and remove the other copy of it from the world then things should start to work.

              Alternatively, if it doesn't make sense to have the SpaceShip as the Default Pawn for whatever reason, you can - for example - have a variable in your Controller or GameMode to store the actual SpaceShip instance, and either find it with Get All Actors of Class, or have the SpaceShip register itself with the controller or game mode on BeginPlay. Then use that in your HUD function.

              Comment

              Working...
              X