Whats the best place to implement these per-Level functionality ?

Hello, I am new to unreal game engine and working on my first game in unreal. It’s a 2d game.

In my game gameplay areas will be defined per level with some sort of method/function to take care of situations when npcs/player go out of bounds.
On some levels, these areas will be as simple as square/rectangle/cricle , etc around the origin and sometimes it can be a custom shape defined by meshes/colliders or something.

I want to make a c++ class/manager that can be picked up by unreal on per level basis that will contain this method MyManager->EnforceMovingObjectWithinBounds() that will take care of any object moving out of gameplay area.

All moving objects will have a custom movement component which can call mymanager->EnforceMovingObjectWithinBounds( newPositionOfObject ) to modify their final position if needed.

I know I can easily hack-N-slash this via a custom actor class but my objective of making this game is also to learn UnrealEngine as much as possible.

Whenever I create a new level of unreal I just want this class to be present by default so even if level designers forget about this there will be this class present in the default state.
So What would be the best way to implement this in Unreal Gameplay framework way of doing things?
A custom GameMode Class?
A custom World class? - I checked documentation but there doesn’t seem to be a way to define a custom world-class per level in the unreal editor?
A custom Level class? - I couldn’t find a way to define a custom level class for any particular level in the editor.

If I was doing this I would define the game area with custom AVolume-based actors and I would put position fixing code into custom movement component. No need for a separate manager class for a simple task like this IMO.

You can make a custom class that inherits from ALevelScriptActor.
Then in the Editor, click the big blueprint icon at the top and open the Level Blueprint.
Then go to File->Reparent, and select your custom level script.

This is how you make a custom level class.

Though yes as stated above it’s prob better to use some sort of volume or box in the scene so you can visually see and adjust the bounds easily.

I have no idea how efficient UE4’s bounding boxes are, and to what extent will you create massive unnecessary overhead - for your needs. If it doesn’t, go with bounding boxes. If however you want to avoid it, I’d recommend setting a simple bounding box manager yourself, and area manager to to speak, something along these lines (note: this is just an idea, not actual code):

struct Area {
 //Node, Vertex
 std::unique_ptr<std::map<double*, double*>> _vertexes = nullptr;
// Ensure

And have a manager class which holds all of your areas, and simply check bounding box entry/leaving on each character move. E.g.

template<typename EventInfo>
AreaManager::CharacterEvent(ECharacterEventType& eventType, EventInfo newInfo)

Ideally you’d have your polygons imported directly from the editor.

Not sure if it makes sense, but it sounds like the best way of combining existing features, the power of UE4, whilst minimizing overhead.

So the way i implemented it so far is that I am using a LevelManger Actor to handle simple gameplay areas like square/rectangle/circle etc with my custom math code to detect out of the game area and redirect pawns back into the game area.
There’s only one gameplay arena per level.

I think a custom levelscriptactor should way to go for future, maybe I will change it into that in near future.

However for custom or complex levels without any simple shape to define gameplay area, I think a bunch of collision volumes might work, I will try to remember and update this thread when i get to those levels. Right now all levels are based on simple geometric shapes.