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.
asked Oct 13 '16 at 12:49 AM in Blueprint Scripting
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.
answered Oct 13 '16 at 03:20 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here