How to get variable from an actor blueprint on screen via HUD

I can not believe I have to ask this here! Such basic stuff… but UE4 manages to put a ‘learning curve’ on it.
Anyway, here comes:

I started a new scene with starter content and I have:

  • two narrow capsules and one HUD, all as blueprints
  • I added a float variable to capsule 1
  • I add capsule 1 via add variable to capsule 2, and can read the float from capsule 1 with capsule 2 (blueprint communication) ->> works
  • I can not do the same for capsule 1 and the HUD blueprint, it gives error saying no capsule could be accessed. Workflow is the same as for capsule 1 <-> capsule 2 communication.

How do I get my capsule 1 float on screen via HUD (not the rolling debug text)?

This doesn’t directly answer what you are trying to do, but you could just move your float variable to your gamemode BP, and then just cast to it & access it from anywhere.

Hello,
Have you set your reference in hud ? If your capsule is in level blueprint : “Create a reference of capsule 1”. On event begin play get player controller / get hud / ( edit : / cast to your hud ) / “set capsule 1 variable” with reference. If capsule is spawned, do the same and set with the return value of “spawn actor of class”.

The capsules are just ‘shape narrow capsules’ dragged into the scene and then turned to blueprint. Communication between them works fine (eg passing variables), but communication to the HUD blueprint does not and gived the error.
I am a bit staggered because I have done this type of BP communication hundreds of times, and suddenly, when I want to create my first HUD, it fails.

How do you access/cast the variable into the HUD/widget blueprint? -> post a screenshot of your setup :slight_smile:

  • what exactly are you trying to create?

So you want to get a value from a variable which is stored in an actor blueprint into your HUD so that you can display it?

Yes, that’s what I try.

I took screenshots. It is easy to replicate in literally 1min: create a new project with starter content and add the 3 BP as shown.
What you see in the screenshots is what I did straight after creating the new project. Nothing else.

When I print capsule 1’s float variable by ‘print string’ in capsule 2, it works. So BP communication works. (screen 1,2,3,4)
When I want to the same with the HUD BP, I get the error. (screen 5,6)
It is the same error that I get, when I do not set the Capsule 1 as default in the Capsule 2 details panel after adding it as variable.

How can I work with capsule 1’s variable in the HUD Blueprint? Very simple, very basic question.

&stc=1&d=1432448765
&stc=1&d=1432448778
&stc=1&d=1432448792
&stc=1&d=1432448804
&stc=1&d=1432448814
&stc=1&d=1432448826

How are you creating the HUD though? How are you setting the reference to Capsule1 in TestHUD? That will not automatically be set. You are better off utilizing the GameMode. Create your own GameMode, for example TestGameMode and put variables on them to store your capsules and HUD references. Then when you need to access something on one of those objects, simple get the current game mode and cast it to “TestGameMode” and grab the correct reference.

Tommy.

Tommy, your reply does not help me.
How do I communicate between a blueprint HUD and a narrow capsule BP to pass variables?

How I set it up:
It is all in the screenshots.
HUD is created by right-click, then new class, then all classes, then HUD. Just the standard way.
GameMode as well by right click, then add class, then game mode.
Then select GameMode in WorldSettings. Select HUD in GameMode. The usual stuff.

Referencing is done by direct blueprint communication (add new variable in blueprint, then for type choose the other blueprint)

Let me rephrase:
How do I use my narrow capsule blueprint and my HUD BP with method 1 here:
https://docs.unrealengine/latest/INT/Engine/Blueprints/UserGuide/BlueprintComms/index.html
(Simple Way to Reference a Target Blueprint )
That’s how I communicate between the capsules. It does not work with HUD BPs!?

Guys, just replicate the scene how I desctibed it and try yourself, it is really only 1-2mins!
Do it with the narrow capsules to represent any scene object, and not some special player BPs or something.
How to I get a variable from any mesh in the scene that is a blueprint to the HUD Blueprint to plot it on screen ???

Somehow it’s not working in the way described in the documentation (dont know why -> casting to a HUD class is always a pain :p), but there is an other easy way to do it:

In your capsule 1 actor bp you will have to cast to your HUD blueprint (that’s easier than casting from the hud to the actor) and from there set a variable in the hud class:

Actor BP:

HUD BP:

I give up :frowning:

Try Yourself, here is the challenge!

I quickly set up the basic scene: two capsules, one HUD BP, one GameMode. (2MB)
Whoever gets the TestVariableforPassing from capsule 1 displayed using the HUD BP first, gets my $30 from the marketplace transferred.
I still have those from when EPIC went free. There is nothing worth it fro me on the market place right now.

Please post screenshot of successful display and all necessary blueprint nodes and settings!

I am not getting it done using Epics’ UE4. Such a basic thing. If I attempt the same communication for capsule 1 <-> HUD as for capsule1 <-> capsule 2, I get an error.
Right now, the TestVariableforPassing is printed using capsule 2 (the rolling 999999). I want it displayed where the text is instead.

Link (only 2MB):
https://drive.google/open?id=0B_...RUE&authuser=0

ScreenShot right after Play is pressed:

Cheers 5347, that solved it.

also posted in the other thread.

Wil turn my $30 into $15 each.

Tried But No Luck

I tried this exact same thing and I get a stupid error message. What am I doing wrong? All I want is for my points Variable attached to my actor Object to be displayed on my HUD. Please Help.