HUD progress bar stays at 0

It works fine for my player health and weapon energy, however, for my turret’s weapon energy (drains at every shot), the progress bar remains at 0. and I think i did everything right. Can you help me?

285173-gfg3.jpg

The float is a default of 1,0. When i remove the minus-float, the energy bar stays the same → black. There are no other references attached to it. In Widget Designer, the “percent”-value is 0,5… that’s about all i know.

I bound the player’s health to this bar and that works. They’re made of the same scheme as the other bars: duplicated and rewritten for the appropriate float…

The CastTo is fine. The HelpTorus is a child actor of my FirstPersonCharacter… could this make it quirky?

While I don’t technically see a problem with this working from the screenshots provided, I think we’d need more to be sure. What does energy start default to? Did you confirm the value is high during the game? Does it decrement properly in code but just not visually work?

It may be easier to use normal numbers (like 1-100) for your energy levels, and then simply use a “Normalize to Range” node to get your 0-1 percentage value, but that’s semi-unrelated.

Are you sure that the “cast to HelpTorus” is successful? If that fails the percent will never be read properly. Is this the same way you setup the other bars?

If that is all correct, my suggestion would be to start looking at the widget attributes to ensure it’s working. Try setting that bar to use the same code as another bar and see if it works normally.

It does print 1.0 for the float and “0.0” when I link the progress bar to the string.

In that case it really seems like your float is 0. When you print a string with the value of the float on the percentage function, what does it output?

If it prints 0.0 when you add a Print String node to the percent, it seems like it’s failing to cast properly. It should cast to child actors just fine. Drag off the “Cast Failed” and have it Print a string and see if you see it in the logs. You can also add a debug point and just watch to see if it fails. Maybe put another return node on there for the failed path that just returns .5.

Bump… still didn’t fix it… could it be that the progress bar won’t read the values of child actors? Or do I have to use CastTo differently?

So now I’d drag off the player character node and hook it up to that Print String to see what class it is coming in as, and then ensure that you have your parent/child setup properly

Sorry, your “Get player character” node, hook that up to the Print String you added on the failed route so that you can see what class it is.

Right, so your character in the game you are trying to read the Energy from isn’t being used. In your GameMode, ensure you’ve selected your HelpTorus child class as the character you want to play as.

In that case, you will need to get a reference to that Torus. You can do this in your FirstPersonCharacter, setting a variable so that the Player always has a reference to the Torus.

In your Percent function you can then

  • use the Get player character node
  • cast to the FirstPersonCharacter
  • get your Torus variable
  • get the energy

The other option is, as you said, to simply store the energy on the player (and change your Cast to the FirstPersonCharacter), and then make your Torus change the Energy value on your player.

Where are you setting the percent of that bar at?

If your Torus classes are being attached as children to the first person character, that answer would work. You can use

  • Get Player Character
  • Get Child Actors
  • Get ( 0 ) “a copy”
  • Cast to HelpTorus
  • Get Energy

But this will only return the first Child actor. This is also not the most efficient method as that is fairly heavy for just reading the energy variable constantly.

Well If both of those images are of the specific progress bar you’re asking about then the first issue I see is that your bind event is tied to get percent 2 not 3. The other thing is, where are you actually using get percent 3.

Ok I see you are plugging in a float value, now where are you actually using it?

Hey I got a hint… Player index. Maybe i have to set a different player index.

How can i see these indexes from my HelpToruses?

Wow, it really does…
What now?

285274-failed.png

(250 is a walk speed)

Character node - which one and where?