which current game mode are you using?

I have a base gamemode, it is a parent to other game modes. The base has a boolean ‘isTeam’ to set if that mode is a team based mode.

So in a Widget I pull up, I want to check to see if the current game mode ‘isTeam’ or not. I can ‘get game mode’ and cast that to a mode, but that wouldn’t work because I don’t know which game mode to cast to, could be any of them that is running. So how do you go about pulling which is currently running so you can check the proper ‘isTeam’ variable?

Uh… thanks, but that’s not what I need. I know the game mode class I load with the level is a child. I need to know how blueprints KNOW which game mode is running so I can pull a variable from it.

To explain perhaps better. I have two Game mode classes, ‘TDM’ and ‘DM’ … they each are children of a ‘base’ game mode class… so they both have an ‘isTeam’ variable inhereted from the base class… when I ‘open level’ with the right string so it loads the level and the chosen game mode… is there a way for the BP to know which game mode was loaded?? So you can then get ‘isTeam’?

Normally to get a variable from a game mode you would ‘get game mode’, then cast that to ‘gamemodex_BP’ or whatever your mode was called. I can not cast to a specific one, because i could be running one of many…

Certainly there is some ability to do this without creating a bad hack job.

Just use ‘Get Game Mode -> GetClass’. From there, you can do a variety of things to compare, you could even create an enum representing each game mode and switch based on the class display name, or just switch on string.

Thanks. Can’t figure out where to go from there. I just did the hack version for now. In the base class I have a function that just grabs a string from the game instance that get’s set when they select the mode, and does a switch on it… so horribly hackish.

should work http://puu.sh/l5RJG.png
get class from any actor and than reconnect to game mode.

CriErr, honestly, I have no idea how that relates to my question in any way.

my first post one, would give you opportunity to check is class is parent off
which means if you have
[base game mode] which has childs like [TowerDeff][DeathMatch][TeamMatch]
and [team match] has childs like[3x3x3][5x5][2x2]
your get game mod return [2x2] compare for child of [2x2] would return true; compare to child of [teamMatch] would return true.
thats if you want to hunt specific game mode branch, if some feature exist only in one of the branches, only in [teamMatch]

get class would give you ability to compare one class to another directly, if your feature exist only in one exact specific class.

if you [base game mode] has bool variable [IKNOWTHEBASICIDEAOFINHERITANCEINOOP]
this variable would exist in every single child of this class and you always can cast to [basic game mode] class to get it, even if current one is [3x3x3], same as variable [pawn controller] is available from pawn, actor and from any custom child of any of those classess which you would create.

Also there are interfaces, which can return any variable from any object no matter of class and if interface dosnt exist in target object it would just return null.

so the ‘isTeam’ carries through in terms of I can cast to my base_game_mode and get it, and it will show the value of that for the actual game mode I am in. Thanks.

With that logic I thought that the ‘Event BeginPlay’ from the base would default for the children, but I guess that doesn’t carry across like variables do.

begin play is carried as “parent begin play”

Ah, right click and ‘add call to parent function’. Thanks. Makes more sense to put as much ‘generic’ stuff there, as that is the point of having a parent class.

Thanks, that lead me down a road where I learned quite a bit… but take note, if you expect ‘get game mode’ by itself to return the exact name of your class… nope, UE4 add’s #'s to the end of things as it instances them… so you might have TDM4 or something. Don’t get caught in that trap. :wink:

i dont use get name anywhere, no reason for it, most of current code is made on basics: actor, controller and user widget - thru interfaces. I don’t use casting as a tool for a connection between any custom classes, only those basics. But that’s might be because im developing spell system and not actual content.