How to specify Default Level Blueprint?

Hi,

There is this few sentences in the docs about Level Blueprints:

"Each game can specify the default Level Blueprint class in the DefaultGame.ini config file. The Level Blueprints for all new maps will be created using this class allowing for game-specific additions and functionality. "

However, when I open that config file there is no such thing as Level Blueprint that I could change. Do I need to type in something manually? If so, what?

Any help would be appreciated, hope I will have better luck here than on AnswerHub.

Just open the project settings in the editor and go to Maps and Modes on the left, you can set the default editor map that loads as well as the game default level.

Well I was aware of that setting, so it seems like I misunderstood the whole thing, or I wasn’t clear enough with my question. The settings in the Maps&Modes tab only allow me the set the default level of my game and the editor, which is not what I’m currently after.

I thought that throught this I can set a Default Level Blueprint and every new Level Blueprint I create will inherit from this, keeping all the variables and functions of the default one, allowing me to add more funcionality for each level. Would this be possible?

No that is not possible. A level blueprint is just for the level.

What you want to do is put that information in your game mode or game instance blueprints.

A level blueprint should only be used for things which are specific to that level and never going to be used or replicated again.

Or use GameState, its replicated, its one of easiest references to get, and it always points to correct blueprint in multiplayer.

Okay, that clears it up a bit, thanks for the heads up.

However I am not sure how I could implement my idea then. Basically I have a few maps/levels with 6 different spawpoints in each. I want to build a system that puts every player to a randomly selected spawpoint at the begining of each level. Do I implement it in the Game Mode then with setting up “XX Map Loaded” Events for each map, and I connetct these events to the same system?

Thanks.

A follow up question on this: Are there any other reasons to prefer the GameState over the PlayerController except multiplayer replication?

No for singleplayer player controller is fine.

But in multiplayer it is complicated.

For spawn points i created custom blueprint that is BP_Spawner.
All it has is mesh that is visible only in editor and has no collision.
Then in game state at begin play i do “Get all actors of class” (that is bp_spawner)
Get thier world locations , and randomly spawn players in one of them.

You also have player start actor, it works fine in singleplayer, but for multiplayer i think it needs session setup.

Thanks for the answer Nawrot, now I have a clear idea about the approach.

May I ask what parent class did you use for the Spawner? I guess a simple Actor will do the job, just want to be sure.

Also, if I implement my ‘random spawnpoint selection system’ in the Game Mode, I just use a Level Loaded Event and connect each of my levels to the spawpoint system?

Is this seems correct or am I missing something?

this is all what spawner is:

  • new empty blueprint with added static mesh that has no collision and is invisible in game.

That is all. It does not need any code inside. It is just marker for “Get all actors of class” > get their actor locations.

In your level loaded event. get game state reference, cast to it, then call some spawning function, that adds players.

Thanks again Nawrot.

If I only use that Blueprint to set a positon, aren’t Target Points something I should consider using? Or are they for something different?

But can the game state run code for each streaming level or just the persistent level. The reason everybody is asking for level BP parenting is because we want to implement functionality to run on every one of our levels, streaming levels or not. Basic stuff that is absolutely necessary for most games. Why the limitation on level blueprints is an absolute mistery.

All that mess and limits are for two very simple reasons:

  • object oriented programming (to load and run child you need load and run parents code, and those chains may be really long)
  • and anything to run it needs to be loaded

Streamed levels are not guaranteed to be loaded, so there are limits of what can do what. And kicker is, due to that object oriented setup (and fact that something must be loaded first) You never know if other actors are loaded when you execute constructor or begin play.

And then on top of that all you have two different hardware systems, each with its own copy of engine. And then you are trying to replicate and load it all like it was commodore64 game.

I think best way to avoid all that mess is event driven setup. Evey actor in game is independent and listens to some events. Default settings can be loaded from data asstes. However I did not tried yet to code complicated game like that.

With level blueprint, there’s seem to be a hierarchy. As far as I can tell, the actors run first before the level blueprint itself, for example.

Well, that’s most games, if you actually want to do anything proper.

Have you tried this only in editor or also in standalone and then cooked games? Because i seen differences between actors loading order.

I battled your problem, and only real solution to be sure game will work in all forms, is to make single actor that loads first. Then build everything else assuming that everything else loads in random order. That and use data assets/tables for storing default values, instead of reading something from another class (that is loaded or not).

1 Like

Thanks. I haven’t tried cooked build with this yet. I thought the game should behave the same as you see in editor, otherwise this is insane: you do things one way, only to see they run in a different way, in cooked. Lol, might as well move to Unity and save myself the mental asylum bill.

Doesn’t work in my case, I need to hand place many actors in the level.
Haven’t thought about data tables, thanks for that.

Yes this is insane, editor “helps” you (the developer) by keeping all things working together during development, but standalone/packaged game does not care. Also in editor most things are loaded when you open project, in game not so much.

1 Like