Download

Where should I put global code? Is the game mode the best place?

Hi,

Where is the best place to put global code? I have two examples.

The first is game states? For example, isPaused, isTalking etc.

The second is world events. For example, let’s say I have a puzzle with 4 objects I turn them all on and they all rotate (for example). Where is the best place to put the check logic?

When I used Unity years ago, I usually would have an empty object where all of my code would go. Is there something similar in unreal?

Any advice would be appreciated.

Like this:

Small number of objects related in some sort of puzzle:

  1. Put them in one BP unless they are scattered around the level

  2. Then put them in the level BP, unless they are scattered across many levels

  3. Then put them in the game instance, unless they are scattered across many game plays ( times playing )

  4. Then put in the save game

Thank you for that. It’s really helpful.

Why should we put it in the game instance versus game mode?

Game instance exist while the game is running, it’s what it’s there for.

Game mode is actually supposed to be just a configuration BP, which shows the system how to connect various articles ( controller, character etc ) to run the game.