I had it on my character BP, I moved it to the HUD and it prints out 0, when I exit I get an Error Accessed None ‘K2Node_DynamicCast_AsFlying_Pawn’ from node Cast To FlyingPawn in blueprint my_HUD. I checked is variable and it is till not working.
The Accessed None Error could come from a few ticks that the Bind tries to use the variable before the OnConstruct actually fills it.
I normally bind a function instead of a variable and then you can use a “IsValid” node for the Pointer/Reference Variable to make
sure that you don’t use it when it is NULL/empty.
Is the Health Variable also 0 in your CharacterBlueprint? Because if yes, then you have some false calculation going on there.
If not, then you might want to bind a function instead of the variable.
If in Character BP value is correct, but in HUD isn’t, then the problem is that it isn’t getting the value correctly.
I guess I found the problem exactly. It is in your second image (and other things, but step by step). I guess your “My Character” isn’t a “pawn” type and your “get player character” I replaced it with a “get player pawn” (well, atleast should be a pawn right? if not, you can’t move it)
With this code I am making a reference to the pawn controlled by Player index 0 when widget is created.
This other code is where I checked the value of the “binding” of a text in the widget. It update the text correctly with the “pepe” variable value in my characterBP.
I hope this help you
Edit: eXI posted while I was writing :P. Thanks for explain that error! Btw, look like the OP have the correct values in CharacterBPs, atleast it is was look in the video.
Edit2: I guess I learned somethings with this thread ^^. Ill practice the references again. If I said something that make you move your hand to your forehead and move your head side to side, please forgive me. Ill work harder to learn more.
So the problem could be only that he is trying use a variable that still doesn’t exist? That could explain why my code worked, because I did a fuction instead a variable reference for the bind (I must admit that I don’t know how to bind a variable directly there :P).
@anonymous_user_28d2a8b8: You also need to fix something. The “NOTE” displays it. In a function, each possible exec needs to end in the Return Node.
In C++ this will give compile errors if not! That’s why Epic made multiple return nodes in 4.9.
To get this working i do the following:
Create a LocalVariable for the Function. Make it the same Type as the ReturnValue (text here). Now, use 2 Set Nodes for this variable.
One Set node is for the working part, where you just plug in your “pepe” value. The other one is kept empty and all failing execs will
go into it. Like the CastFailed.
This fill fix the Warning and should always be used!
A self made Struct. Structs are good to save a bunch of variables and keep them together.
You can create your own.
But let’s not further spam his thread here with other topics. If you need help with structs etc,
feel free to open your own thread.
@OP: The Screenshot i posted in my other post above is how you want to make your Bind Function.
But you will take the Health variable and not a Struct like i did. Then you select this function for the
percentage bind.