Cast To GameHUD

Thx a lot, this is indeed a lot easier.

Quite obvious actually… problem is when I’m following a tutorial I forget to think for myself :smiley: That usually comes afterwards when things are working and I can analyse and fully understand it :slight_smile:

Perhaps for others, this is what I got:

Pro-Tip: Instead of calling Set HAmmoMax after constructing the widget, you can set the variable as “Expose On Spawn”, and it will show up as a Pin on Create Widget nodes that construct that type.

Even better, thx a lot!

I’m actually also running into a similiar problem in the next part of the quick start guide 5. Experience Bar and Hotbar Button. Its a little different, but perhaps the reason is kind of the same?

It’s about adjusting the ‘MyProjectile’ Blueprint so that when you hit a box you gain experience. I’m am not able to do what is stated in part 3. Off the As My Character C pin, Get GameHUDWidget (our Widget Blueprint) and Cast To GameHUD.

Again I am not able to ‘Cast to GameHUD’. I tried doing it differently with a create widget node with the GameHUD as class (like the previous solution). Here is a screenshot of what I got:

The calculation is made, as I can see because of the print string I added, but the results aren’t written (or cast?) to the actual GameHUD. Can I cast directly to the gamehud or do I have to first use a ‘cast to mycharacter’ node? I tried several options but none seem to work.

I am stuck also. I will keep playing around with the UMG and hopefully soon the documentation will finally be updated and the tutorials will be in sync. I need a better understanding of how blueprints work… It’s less foggy to me, but not clear enough for me to efficiently use it. Back to the beginner tutorials :slight_smile:

I meanwhile ‘solved’ it with a ‘cast to MyCharacter’ node in the ‘MyProjectile’ Blueprint (casting the calculation to a float variable in the MyCharacter blueprint). I than fetched that same float variable (again with a ‘Cast to MyCharacter’ node) in the ‘GameHUD’ blueprint and used that as the percentage of the experience bar.

This basically does the same as what is intended in the quickstart guide.

Here you can read a bit more about when and how to use what kind of communication form between blueprints:

But it looks like either the documentation needs to be updated, or the things described regarding casting aren’t yet implemented in unreal or something…

Sushichris, Eggbird and other contributors,
Thanks for this thread, I ran into the same problems when I tried the UMG Quick Start Guide yesterday. Thanks to the info in this thread I eventually got the tutorial example working.

While I can’t pay you back (as your problems were resolved) I thought I could perhaps pay it forward to others that may hit this same obstacle so I have had a go at re-writing the problem sections of the Quick Start Guide. The Dropbox link below contains a pdf which includes all six sections of the Quick Start Guide and combines the solutions suggested in this thread. Where the instructions have been changed I have outlined the old instructions in grey, and the new instructions are outlined in red.

The new guide suggestions implement 3 basic changes:

  1. Change H_AmmoMax to “Expose on Spawn” (thanks Nick Darnell for the pro-tip)
  2. Remove the need for the variable GameHUDWidget by using Cast To MyCharacter instead.
  3. Add a new public variable P_Experience in the MyCharacter blueprint which has scope to the other two blueprints (GameHUD and MyProjectile).

I’m sure there are better ways to do it than I have done, but it works (for now :p) and hopefully someone else having the same issues will find this thread and get some value out of it.

https://db.tt/HXHGPFmT

At least it was a good exercise in learning about blueprint communication (maybe that was their intention all along (Illuminati confirmed :eek:))

Like , I want to thank ALL of you for this very helpful thread. I was really pulling my teeth out on this tutorial. Reading it through and figuring it out helped me fix several other blueprint problems I was having because of version issues. A special thanks to Nick for the Pro Tip, it is something I never thought about using before but now I can’t stop.

Finally to , thank you very much for putting all the comments together to the fix this tutorial. What a great pay forward!

Guys, after reading this and playing with this thing, I guess I found out what the problem is:

When you promote to variable the output of the function “Create GameHUD_C Widget” You are creating a variable that is already a GameHUD var… that’s why when you try to access it from MyCharacter, you already get an object GameHUD… that’s why unreal engine doesn’t understand you when you try to cast it into a GameHUD object!


BUT if you create a generic variable that will contain a generic UserWidget Object (which is the parent class of our GameHUD blueprint) voilà… it will be able to contain any UserWidget blueprint, including our GameHUD blueprint! which we do when calling “Create GameHUD_C Widget”.

wow, these things get out of hand so fast. get this:

(step 7 in #4) Just leave the ‘Cast to “GameHUD”’ out! (or whatever you named it) but you still need to set it as in step 4 in #4 Displaying Ammo, Health, Energy part of the tutorial. So you can use it later, just follow the steps in tutorial. Also, if you ‘Read’ step 8, clearly states to compile and save. :wink:

Same goes for #5 Experience Bar and Hot Bar Button, step 4 of Generating Experience and Finishing Up -> Leave It Out!

You can pull straight off of the blue pin of your HUDWidget (whatever you named it) to access the rest.

Don’t make these things no more complicated than they already are, I see this so much when looking at others work. Saw one that was almost a full page BP that was easily done in a few steps. And trust me I’m new and no wizard with this.

good luck to you all, this should help a lot.

ps: this was also a huge pain to me as well, so you are not alone! any further issues can sometimes be resolved simply by saving or compiling and even at times, restarting editor. again good luck & happy programming.

ps: this was also a huge pain to me as well, so you are not alone! any further issues can sometimes be resolved simply by saving or compiling and even at times, restarting editor. again good luck & happy programming.
[/QUOTE]

As a total newb getting into this, and trying to follow the tutorial, this is a huge pain in the butt. I wish the tutorial was updated.

Is there any chance the tutorial might be updated for those who want to use the full step-by-step?

Did you try the updated step-by-step version I linked above? https://db.tt/HXHGPFmT

I’m not sure if anyone else has tried it yet so I would appreciate any feedback you have. Cheers.

Updated the tutorial, looking back at this… I’m not sure why I was including the Cast To GameHUDs (shouldn’t have had to do that)… this was done awhile ago and I’ve had some more time with UMG (Nick’s Tip I’ve included in it as well).

Not sure when the updates will be published, but I’ve made the changes and will link it when it makes it to the next change list/version update.

-W

Great! Thx everyone for the helpful input!