Download

how do i cast saved data to my hud?

Hey guys,

firstly, i posted about this issue on the answer hub 20 hours ago, and it hasnt had a single answer yet so i thought i’d post here aswell since im eager to get a solution to this matter, as i feel its only a simple piece of knowledge im not aware of.

So absically, i’ve made a endless runner game and it features coin collecting, which can now be accumulated over a period of time thanks to the use of save game objects which stores the integer for me. However, i’d like to be able to cast this value to the hud so the player can see their total coins collected (which could then be spent in a shop etc)

The issue itself is usually im able to cast data to the hud when the interger for example is found within the third person controller as then on the cast to node. the object pin would be conencted to ‘Get Player Controller’ but in this instance, with save game objects i have no idea what node to hook the object pin upto.

savegamehelp.jpg

Thanks :slight_smile:

I believe you want to load saved object and point that to it?

You need to load it first. Either in the Widget or somewhere you can access the Data. For example your GameInstance.

What you DON’T want to do is the following:

Load the SaveGame in function you have open in the screenshot (GetText2), BECAUSE this is a binding and bindings tick.
So you would constantly LOAD the SaveGame. Although you only need to do that ONCE.

And what you also DON’T want to do is:

Plug the “CastFailed” exec into the ReturnNode. Because if the Cast fails, the “AsMySaveGame” Reference will be NULL, means you are
trying to get the Coins variable from a NULL Reference. That’s a bad nogo and leads to “AccessedNone” errors.

What you WANT to do, to fix that:

Select the ReturnNode and simply copy paste it. So you have 2 return nodes. Now return a plain, hard coded ReturnValue Text when the
cast fails and only use the Coins variable when it succeeds.

Thank you! I have managed to solve this issue you have both been very helpful! :slight_smile: