Use Custom Game State

hello i am doing a game state for my project( example: start menu , level select , level1,level2 etc) and i have been using a simple string and in the function checking to see if the string is equal to startmenu or levelselect etc.i have looked online for a more proper way of doing this and i cam across enums. some sources say use namespace with enum Type and some say use enum class. which method is better for simply checking and setting a state. and how would i check/set the enum to a particular value. I have tried the enum class method however cannot change between them.

They’re both valid methods and just as easy. The enum class is the more up to date method.

Alternately, instead of using a string in a function, you can check GetWorld()->GetName() - that will return the name of the map.

so if i am using the enum class method can i actually have one of the values = true and the rest = false and switch it up when i need?

No. Enum values can’t change. You need to compare them to something. you can do MyEnumVar == MyEnum::Blah to get true/false. But you need that MyEnum::Blah to compare it to.

Another method would be to change the game mode for each map (in the world settings.) You can override any methods you need to change or override variable values, etc.