Announcement

Collapse
No announcement yet.

Cast To GameMode always fails

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cast To GameMode always fails

    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:
    Click image for larger version

Name:	CastFail.jpg
Views:	1
Size:	512.7 KB
ID:	1175273

    Thanks.

    #2
    Make sure that myGameMode is set as the default gamemode under Project Settings > Maps & Modes.

    Comment


      #3
      Hi, thanks for your answer! I forgot to mention that it is!

      Comment


        #4
        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!

        Comment


          #5
          Hi everybody!

          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.

          Thank you in advance!

          Comment

          Working...
          X