Casting the GameMode fails

Hey…
I try to cast my custom GameMode in my Pawn class…but it fails to cast as GameMode, therefore I can’t access the variables I try to get. It’s just a small single-player game. I store some vectors with spawn locations in the Game Mode class.

What I did:

  • Set my GameMode “BP_GameMode_Tutto” in the Project settings.
  • And the “BP_GameMode_Tutto” is set/loaded correctly in the World Setting of my level

  • I’ve set the variables in the BP_GameMode_Tutto class to public.

  • I’ve added a breakpoint to see what I get…I get the correct Class returned (Execute comes from “Event BeginPlay”)

  • But the Cast To GameMode fails

Any Idea why it still fails to cast it?

Solved it myself.

The problem was that I casted to “GameMode” instead of my custom game-mode “BP_GameMode_Tutto”.

So it was not able to cast “GameMode” to my custom one.