# Create Level class?

**URL:** <https://forums.unrealengine.com/t/create-level-class/40921>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [September 6, 2015, 2:07pm UTC](https://forums.unrealengine.com/t/create-level-class/40921 "2015-09-06T14:07:12Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![RumbleMonk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RumbleMonk](https://forums.unrealengine.com/u/RumbleMonk)\
**Post date:** [September 6, 2015, 2:07pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/1 "2015-09-06T14:07:12Z")

</div>

Hi, I’m trying to be a bit smart with how I create my levels. Currently I have some stuff that gets run once when the map gets loaded, but I aim to have lots of levels and any change I make to how I handle my level data in the future would mean I’d have to go into every single level BP and copy/paste nodes.

Is there a way to make a level class that has all my level BP nodes and create level sub classes from that?

If there’s a better way to deal with this I’m all ears.

Thanks!

---

<div class="post-metadata">

**Author:** ![arbopa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@arbopa](https://forums.unrealengine.com/u/arbopa)\
**Post date:** [September 6, 2015, 2:30pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/2 "2015-09-06T14:30:54Z")

</div>

Would like to know this one too, as it seems you can not make ‘children’ levels like you can with BPs.

---

<div class="post-metadata">

**Author:** ![Staggerlee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Staggerlee](https://forums.unrealengine.com/u/Staggerlee)\
**Post date:** [September 6, 2015, 2:49pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/3 "2015-09-06T14:49:47Z")

</div>

blueprint function library springs to mind as a work around

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [September 6, 2015, 4:00pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/4 "2015-09-06T16:00:06Z")

</div>

Another option is to have a “level populator actor” which you can place into each of the levels, and have that actor (rather than the level blueprint) do the heavy lifting.

In general, the level blueprint should have as little code/nodes as possible. Just a few event handlers that immediately delegate to GameInstance, GameMode, or some known Actor in the level.

---

<div class="post-metadata">

**Author:** ![arbopa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@arbopa](https://forums.unrealengine.com/u/arbopa)\
**Post date:** [September 6, 2015, 4:33pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/5 "2015-09-06T16:33:30Z")

</div>

What is a level populator actor? Have not run across such a thing.

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [September 6, 2015, 6:20pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/6 "2015-09-06T18:20:40Z")

</div>

> [@](#):
>
> What is a level populator actor? Have not run across such a thing.

It’s an actor of some class that you define, which you make do all the heavy lifting. There’s no pre-defined class for this, but a pattern of building a blueprint actor that does all the work, rather than doing the work in the level blueprint.  
The level blueprint could find this actor (for example using “all actors of class”) and tell it to do its thing. All you need to do in other levels is to copy/paste this start-up code; any changes are made in the blueprint actor, which is re-used/referenced in each level.

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [September 6, 2015, 11:47pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/7 "2015-09-06T23:47:53Z")

</div>

I’ve had the same idea about making some parent class for levels 🙂 But since it’s impossible, the “level populator” object seems like a good idea.  
BTW, with 4.9 there came some new ‘level interfaces’, but they probably won’t help here.

---

<div class="post-metadata">

**Author:** ![Variss](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Variss](https://forums.unrealengine.com/u/Variss)\
**Post date:** [September 7, 2015, 3:31am UTC](https://forums.unrealengine.com/t/create-level-class/40921/8 "2015-09-07T03:31:16Z")

</div>

All of my level data/calculations are done using a custom GameMode class rather than the level blueprint (i use GameMode as sort of a level manager). I then just set the GameMode for each level as my custom class. Should be able to make any changes needed then and it will copy through to every level that uses that GameMode. Would something like that work for your project?

---

<div class="post-metadata">

**Author:** ![ZoltanJr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZoltanJr](https://forums.unrealengine.com/u/ZoltanJr)\
**Post date:** [September 7, 2015, 4:37am UTC](https://forums.unrealengine.com/t/create-level-class/40921/9 "2015-09-07T04:37:05Z")

</div>

Yep GameMode is definitely the way to go for this. Then You could use a data table to store the values for what each of the levels should do.

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [September 8, 2015, 9:33pm UTC](https://forums.unrealengine.com/t/create-level-class/40921/10 "2015-09-08T21:33:13Z")

</div>

GameMode is great for things that can happen on the server. The GameMode is not available on the client if you run multiplayer.  
GameState is sometimes a good alternative.

---

<div class="post-metadata">

**Author:** ![Slayemin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slayemin](https://forums.unrealengine.com/u/Slayemin)\
**Post date:** [September 9, 2015, 12:40am UTC](https://forums.unrealengine.com/t/create-level-class/40921/11 "2015-09-09T00:40:33Z")

</div>

I stopped putting logic in the level blueprint because I wanted to have the same behavior across multiple levels. I made an effort to put as little ‘code’ as possible in the level blueprint, and instead, put it into the game mode class, game state class, game instance class, or use blueprint communications to have objects talk to each other. This lets me create any kind of level I want and just set a game mode for it and all of the game logic is brought over.

Some props and blueprints will need to know about other ones. Maybe you have a button which opens a door blueprint. That’s pretty easy to setup with instanced references which bind the button to the door you want it to activate (preferably using Blueprint interfaces).

---

<div class="post-metadata">

**Author:** ![arbopa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@arbopa](https://forums.unrealengine.com/u/arbopa)\
**Post date:** [September 9, 2015, 12:58am UTC](https://forums.unrealengine.com/t/create-level-class/40921/12 "2015-09-09T00:58:46Z")

</div>

> [@Slayemin;374813](#):
>
> I stopped putting logic in the level blueprint because I wanted to have the same behavior across multiple levels. I made an effort to put as little ‘code’ as possible in the level blueprint, and instead, put it into the game mode class, game state class, game instance class, or use blueprint communications to have objects talk to each other. This lets me create any kind of level I want and just set a game mode for it and all of the game logic is brought over.
> 
> Some props and blueprints will need to know about other ones. Maybe you have a button which opens a door blueprint. That’s pretty easy to setup with instanced references which bind the button to the door you want it to activate (preferably using Blueprint interfaces).

All makes sense. I was gonna ask about where you put the code for something like a door that opens.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [September 9, 2015, 1:24am UTC](https://forums.unrealengine.com/t/create-level-class/40921/13 "2015-09-09T01:24:53Z")

</div>

> [@arbopa;374825](#):
>
> All makes sense. I was gonna ask about where you put the code for something like a door that opens.

Simply into the Door Blueprint.  
The door might open by an Overlap combined with enabled Input and pressing a ‘E’ Key.  
Or you press a button next to the door that opens it. The button could be created as a StaticMesh + Collisionbox in the DoorBP too  
or it is an extra BP with a Reference variable of the door that is set to “editable” and you can just use the pipette to fill the reference with  
the placed door.

Check out my “reference and blueprint interaction” project that you can find in my Free Learning Projects thread that i have linked in my  
description right under this post.

LevelSubclass can be created in C++ as far as i know, but BP has its limitations (again a limit that you might want to tell someone if he asks  
what BPs can’t do). But you can use the GameMode class for things like this, or the GameState class.  
Also spawning and referencing ManagerClasses like someone above suggested is a good idea.

---

<div class="post-metadata">

**Author:** ![arbopa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@arbopa](https://forums.unrealengine.com/u/arbopa)\
**Post date:** [September 9, 2015, 1:50am UTC](https://forums.unrealengine.com/t/create-level-class/40921/14 "2015-09-09T01:50:08Z")

</div>

> [@eXi;374837](#):
>
> Check out my “reference and blueprint interaction” project that you can find in my Free Learning Projects thread that i have linked in my  
> description right under this post.

Thanks, will check it out.

---

<div class="post-metadata">

**Author:** ![AlliTriesToCode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlliTriesToCode](https://forums.unrealengine.com/u/AlliTriesToCode)\
**Post date:** [March 10, 2022, 11:22am UTC](https://forums.unrealengine.com/t/create-level-class/40921/15 "2022-03-10T11:22:35Z")

</div>

Posting this here for the sake of completion.  
There’s two ways that I know of to define default behavior across a set of levels:

- The first is using the game mode as has been mentioned in this thread. This is the standard pattern.
- The second is to create a custom level script actor class in native code. The custom class can then be assigned as the level blueprint’s parent class.

While the game mode has more features backing it up, both options can achieve the same result.

The second option is mostly useful for prototyping and edge cases in dynamic level streaming. One example being if you don’t want to constrain the game mode with generalized behavior for your streamed level.
