Hi, I would like to ask for some help regarding my issue.
In my GameState, I am trying to cast to my GameMode, but it always fails and I can’t figure out why. My function is supposed to set the “is Player In Game?” boolean variable to the same value that the “Is This An in Game Game Mode?” variable has, which is stored in “myGameMode”. The cast always fails, here is my Blueprint setup, I can provide more screenshots if necessary:
I may figured out the answer to my own question. The Default Game Mode is myGameMode, however the level I’m using overrides it with InGameGameMode, which is inherited from myGameMode. I guess I have to cast to InGameGameMode itself and then it will succeed. I don’t even know why I wanted to cast to myGameMode, InGameGameMode has the boolean as well, in fact, the correct value I’m looking for is in the currently used GameMode, which is InGameGameMode.
Thanks for your suggestion, it led me to the solution!
I ran into something similar, so I thought I should ask for help here:
So I have put a SetPlayerCharacter into the map blueprint (I am working based on an RTS tutorial). When I debug I see that If execution gets to Cast to MyGameMode it will always fail. Here is my blueprint. This only works when Game mode is set to GameModeBase in project settings. In MyGameMode spawning doesn’t even start even though I have a MyGameMode class (2nd screenshot). I can provide more screenshots if necessary.
First of all ensure you have correct GameMode setup in project settings and in WorldSettings overrides on level.
If that’s not the case, on CastFailed you can print GameMode class name with PrintString, maybe this will give you a hint.