Progress bar not changing?

Did you checked that the cast to Cube is not failing? Is the return node getting called and what does it give you back when you set a breakpoint?

Having an issue where I’ve linked my progress bar to a float value (health):

but there is no visual change in the progress bar it’s always shown as empty in the game:

the value of the health is set to 100, and this method has worked inside previous projects.
Anyone know what would cause it to not be going, though? or if there is a way to check that the progress bar is receiving the correct value?

thanks, Percy

Thanks for pointing out breakpoints tt me didn’t know about them until now. I’m getting a lot of “variable not in scope” I’m not sure if that means anything you might need to break this down for me a bit.

Update: looking into it some more, Yes your right it’s not casting to cube! where do I go from here ?

thanks -P

you can right click on the cast node and convert it to pure to avoid this problem

Thanks, gave that a go but getting the same issue though, it looks like this?

mannnn … you are casting player controller to cube.

if your pawn is a cube, then you must cast the player pawn to cube

get player pawn. then cast to cube

that’s done it thank you so much! Can you explain why that’s the case because in a previous project it was fine with player controller ?

Just to give you a correct answer (you already found out in the comments): you are trying to cast a PlayerController to Cube that inherits from Character or Pawn. They are incompatible, so the cast is always failing.

If Cube would be inheriting from PlayerController instead and defining a variable Health, then this would be fine. But this is not the case and you should not change it to that.

The solution would be that you retrieve the pawn the PlayerController is controlling. You can do that with the [GetControlledPawn][1] function. After that you can cast it to Cube and do stuff.

Alternative: you are using GetPlayerCharacter. This retrieves the Character directly.

Here an example blueprint:

Thank you for explaining! this helped a lot