x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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.

Product Version: UE 4.13
Tags:
more ▼

asked Oct 13 '16 at 12:49 AM in Blueprint Scripting

avatar image

cmdrkickass
1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

alt text

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.

gold.png (51.6 kB)
more ▼

answered Oct 13 '16 at 03:20 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question