How to do this?

image
this is probably a really basic question, but i’m trying to reference a variable in the game mode after casting to it. i don’t know how to make the node look like this. this is how it looks:


i need the ‘as game mode’ to connect to an integer variable from the game mode.

Hi, in your second image you would need to cast the output of GetGameMode to your specific game mode class, instead of casting to the generic parent GameMode class. Then you can access the variable.

Also the GameMode does not replicate, it only exists on the server, the clients can never access it. Therefore setting the TestVariablefromGM to replicate won’t do anything. If you want to set some variable the clients can access as well, you could use the GameState (GameState does exist on the server and all clients and replicates).

1 Like

I do the same thing essentially, off of begin play of whatever bp I get a GM ref and then access whatever I need from the GM through that ref.