GameState returns null?

I strongly advise you to move your Get Game State function out of the Blueprint Function Library. Whenever I try to put anything like this (for example Get Game State, Get Game Instance, Get Player Controller etc.) inside a Blueprint Function Library it always results in random error eventually. The thing is it wont happen immediately. Even after immediate restart also nothing seems to be wrong. But once the project starts growing and you refer these functions in different Blueprints, slowly random errors starts to pop up. Previously using something similar to this led to corrupted project. I am not saying that you should completely avoid using Blueprint Function Library but try avoiding anything that refers GameMode/State/Instance, PlayerController, HUD, PlayerState, Character etc. It seems that these issues only happen if you use it from Blueprint. I have custom Blueprint Function Library in C++ that refers GameState/Instance etc. and they work without issues.

Sometimes when starting the game (multiplayer only) the build-in GetGameState returns NULL. I tried to playtest it like 10x and 2 out of those 10 times on start I got this printed message from my own (function library) function telling me that the GetGameState is indeed NULL.

I also moved the code out of the constructor (where it happened all the time obviously) and into the EventBeginPlay but it still… Could it be that the GameState is not yet received from the server or something? Because it does not occur in singleplayer. It only seems to occur to client(s).

But I’m also getting this (which seems to be an Unreal bug UE-11411 UE-14581, but I can’t find the culprit):

88080-bp3.png

It sometimes throws that error and sometimes does not (when saving the project). I think this is unrelated but you never know. I also never used Engine/Transient I believe because I can not find anything called “transient” anywhere. Error is temporarily fixed by exiting editor (w/o saving) and entering it again and just rebuilding the unsaved changes again and chances are likely it will save then.

Thanks. Looks like I will have to remove most of my function library then and write the same code over and over again in every blueprint… At least in some functions I could just add the player-controller as a parameter. I’m also considering going C++ here to get around the UE4-bug but that requires me to use a blueprint as the return value which is also slightly messy.

So it’s another UE4 bug? Man I’m just trying to make a simple shooter game and I already encountered at least 4 UE bugs and some unverified ones in just a few days time… I’m constantly using dirty workarounds for bugs that are not mine but are caused by UE4 itself!

  • Bugged text-render component (minor bug but still)
  • Can’t save error: UE-11411 UE-14581
  • This one
  • Structs are bugged when used in array when setting their value since UE4.4.
  • Possible (unconfirmed) bug with collision-components not being the root component.
  • Various desynchs between Visual Studio and UE4. Also when using blueprints off of this (even after restarting UE4 they may still not update correctly and crash the engine randomly).

I wonder if this engine is stable enough to make a game. It improved a lot since 4.7 but the amount of bugs for simple actions in just a few days time is scaring me.

ryanjon2040’s comment fixed it. Tested it many times and now it works every time.

You dont have to re-create stuff from Blueprint Function Library in different other Blueprints :). Consider using Macro Library (extended from Actor) which can contain Game Mode/State/Instance, Player Controller and all that stuff. Note that you cant use Actor Macro Library in an Object class (that is UMG, Components etc.)

Oh thank god. I misunderstood you. So it only (sometimes) bugs when doing this in a library derived from an Object. But deriving from an Actor works. Thanks I will try that out in a second library.

Update: works.

Macro Library and Function Library are two different things. Only Macro Library can be extended from classes like Actor or Object or anything like that. Function Library cannot be extended from Actor.

What i meant was whenever you try to access GameMode/State etc. in a Function Library (not Macro Library) it bugs. But you can access them from a Macro Library easily. One limitation is you can only access GameMode/State/Instance, PlayerController etc if you extend Macro Library from Actor Class. If you extend it from Object then you cant access those nodes. Another limitation is since you extend the Macro Library from Actor class you can only use those nodes inside a Blueprint that is extended from Actor class. You cant use them in UObject based classes like UMG, Components etc. :slight_smile:

It’s still a problem at 4.13.1

please give the path,thanks.