Where to store game rules?

Hi,

I put all the classes that manage my game rules in the game mode. However now I can’t query these from my player (client) class. For example I have rules for deciding where the character is currently allowed to move based on the type of game and the current state of the world. I want to highlight these moveable areas when the player clicks a button. Where do objects like these normally live in unreal? I could move them to the game state but this doesn’t feel right as they are not “state”.

Thanks

Hey SausagesSizzling!

Would you mind sharing your .h and .cpp of your player class?

But to answer your question, these rules are generally put into the “gamemode.”
Hope this helps, feel free to link your code if you have any specific questions about it.

All game rules control should be live in AGameMode and actors related to specific game rules should inform with function calls your AGameMode about interaction with them, then any UI should read out from game mode to represent it graphically, actors can have graphical representation too.

You can extend this with AWorldSettings, allowing to customize world settings with extra properties stored on the level which then you can read out from ()->GetWorldSettings() in your AGameMode, like default frag limit, time limit for your level etc.so you can set per level rules here which other classes would read out from. but AWorldSettings it self should not have any executable code, only store properties.

Per player rules keeping can be also controlled in APlayerController as you can assign APlayerController class for specific AGameMode:

And also actors themselves can react and adapt to specific game modes.

Thanks for taking the time to answer. I accepted your answer (winner by default!) but you say “then any UI should read out from game mode to represent it graphically” but I don’t understand how you do this when the game mode doesn’t exist for clients?