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"

Accessing GameState(written in C++) variables and functions in Blueprints?

So I have my GameState setup in C++, and I've declared a variable to hold the number of players in the server, along with its Getter and Setter, and I've marked both as BlueprintCallable. I want to access this Getter and Setter from a BP, but whenever I do "Get Game State" and "cast to my Game State", I don't see either of these show up in the BPs. I've done this countless number of times with other C++ classes, and I'm not sure why it doesn't show up for Game State or Game Mode classes? Any insights on this would be greatly appreciated. Is this not allowed, and if so, why ?


Product Version: UE 4.18
more ▼

asked Sep 16 '18 at 06:29 PM in Blueprint Scripting

avatar image

30 2 4 11

avatar image mightyenigma Sep 16 '18 at 07:05 PM

Make sure you have that custom gamestate class set in the GameMode you have set in your Project or Level settings.

avatar image hussainAbis Sep 16 '18 at 07:28 PM

It is, but it still doesn't show the functions and variables. Here is the declaration in PGameState.h class, it has been defined in PGameState.cpp too alt text

It is configured properly in the Project settings:

alt text

But I can't access them in the BPs:

alt text

screenshot-35.png (12.2 kB)
screenshot-36.png (24.3 kB)
screenshot-37.png (50.7 kB)
avatar image mightyenigma Sep 16 '18 at 08:06 PM

Does the Server Settings category show up when you drag the pin, before you type anything? Maybe @Shadowriver can help.

avatar image hussainAbis Sep 16 '18 at 08:08 PM

nope. even the category doesn't show up

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

1 answer: sort voted first

It should work normally without issue there no blocks like that and blueprint in reality don't know any roles of classes, it job is just executing code whatever it is.

I notice other issue and i wonder why you not getting compilation errors or at least warnings aspecially from UHT, potentially pointing the issue. Reflection system does not support int type and that time should not be used in UE4 code as int does not have fixed size on all platforms and compilers, in ue4 you should use explicit fixed sized int types like int32 or uint8 (only those 2 types are supported by blueprint system, but other int times are compatible with reflection system and property editor)

First of all close editor before compilation which make sure hot reload is not on the way (it sometiems mess ups when you add new declerations), then click rebuild instead of build which will force UHT to read all header files again. It is UHT job to catch BlueprintCallable function and register them in generated code so blueprint editor could see them.

more ▼

answered Sep 16 '18 at 08:36 PM

avatar image

37.2k 936 172 1116

avatar image hussainAbis Sep 16 '18 at 08:53 PM

Thanks for the response Shadowdriver! I have tried all of the things you mentioned. I was initially using uint8 itself, but I changed it to int later when I started running out of ideas, and to eliminate the type being a reason. I'll revert it back to uint8 although I'm not sure why that would be of problem because I have used int in C++ code and referenced it in the BPs before and it worked. I also restarted the editor to check if it was a hot reload issue, and I also did a full rebuild, but it still behaved the same. I guess it could be a bug? I just wanted to make sure that it is indeed allowed by UE4 to do this in the GameMode and GameState classes? Since I've done this at other places and it's not happening here (in GM and GS), the only thing I can think of right now is that maybe these classes have different behavior than other regular classes?

(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