Passing of variables between blueprints does not work.


I’m running the first person template and I am modifying a lot from there.
I’m trying to pass a simple variable called “Health” (integer) that can be found inside the “MyCharacter” blueprint to the “MyHUD” blueprint. I have added a reference to the “MyCharacter” blueprint inside the “MyHUD” blueprint, see screenshots.

The errors I’m getting are the notorious “Failed to find variable property” and “Accessed None ‘BP_Target’ from node Construction script in blueprint MyHUD”.

What am I doing wrong here? Probably some stupid error on my part but I blame the tiredness from sitting here playing around with UE4! :o

Thanks in advance!


What you’re doing wrong (i think) is using a variable of type “My Character”.

Instead of using that in your HUD, you have to create a “Get Pawn Controller” (sorry i can’t recall the exact name :P) it’s usually set as favourite so you can find it directly on your right panel in the blueprint editor. For this node, drag a wire a plug it into a “Cast To…” (where “…” is the name of your Character Blueprint which in this case looks like its called “MyCharacter”).

Now you’ll get the Cast To node; from there you can drag a wire out of the “As MyCharacter C” pin and now you should be able to look for those variable you made editable in your *MyCharacter *Blueprint. It means you can search (from the quick search box that appears when dragging out the wire from the Cast To node) “Health” and you’ll get 2 choices: “Get Health” and “Set Health”.

I hope this can help you, at least this is how i do it ^^

Thank you! This worked as intended! Now I can continue with my work, once again thank you :).

I’m providing a screenshot below for anyone who is having the same problem in the future ^^:

You’re welcome! I’m glad it worked for you :slight_smile: