How can I access an int variable from another blueprint?

In my gamemode blueprint I have an int variable called Gold. I’d like to directly call this variable in my HUD blueprint to set the width of a yellow rectangle overlayed on top of a black rectangle to use as a sort of meter. Is this possible?

I’ve tried following the documentation page on cross-blueprint communication and looked at casting and searched around online for similar issues, but it looks like they just don’t apply to my specific problem.

Hello cmdrkickass,

You were on the right track, what you need to do is use casting. This will actually be a bit easier since you’re trying to get a variable from your GameMode. You’ll need to set something up like shown below inside of your HUD’s graph:

You’ll use Get Game Mode to get a reference to the current GameMode and the use Cast to MyGameMode (Or whatever your GameMode blueprint is called) and continue your logic off the top (cast succeeded) pin. You can then drag off of “As My Game Mode” and get a reference to your int variable. You’ll then most likely want to store that value locally unless it’s something that will be getting constantly updated, in which case you may want to cast each time you need to use it.