Difference ways to get HUD reference

Hi people,

I’m rather new to UE and what I’m trying to do is fire up a custom event I created in a newly created HUD class from a different blueprint.
I managed to do that (by the method below in the image) but I didn’t understand why one of the ways was wrong and wouldn’t let me access the event.

Can somebody clarify it for me why the first method, the one with the purple node (which I didn’t get, what type is it?C++ class?) wouldn’t work?
Thanks!

1 Like

That a class reference, as you can see it purple which indicates that, you can not access object from it, you can only reference class, to spawn or search for object and other things.

HUD object is created and stored as each player need individual instance of it and you can access it via “Get HUD” node.

Also one note, UMG technically don’t require HUD object, HUD class is primerly for old canvas HUD system (which is still useful as it allows to draw things more freely), so if you want to you can create widget in PlayerController and if you make single player game you can also place it in GameMode.

1 Like

Oh cool, thanks for the reply. Now it is much more clear to me.
About your note, but isn’t it considered generally a “better” game design if you separate each system to its parts and make it more simple to understand and access later on when your project gets bigger and bigger?

To add to 's explanation, the first one you are accessing a “class”, this only allows you to see properties of the class as a whole (variables for example) but it doesn’t allow you to effect change or call functions because you don’t have a specific class “object” to act upon. The second setup works because you are getting a specific instance of the VN_HUD class which has the ability to call functions and things in game. If you are new and want to better understand casting/references check out video #1 and 25 in the link below. I go over both in a beginner friendly tutorial in more detail.

Thank you for the youtube reference, nice playlist you got there!