Is there a C++ equivalent to a Level Blueprint?

I’ve started converting my entirely blueprint game into a C++/Blueprint mix, and I’m still in the stages of wrapping my head around what equates to what between the two. Functions and events on actors make sense to me, but where does the level blueprint stuff go in C++? I’ve tried researching it but I’m not really finding anything that is giving me the answer I’m after. Perhaps I’m just searching the wrong terms or my idea of how this conversion will go is off base.

#Yes There Is

#Solus Level BP Tutorial

Here is my tutorial on this subject, lots of code included!

And pics!

#Summary

There is a C++ base class for level blueprints that you can extend to create your own level blueprints with their own functions and variables

you then re-parent the level BPs of any existing levels to your new level bp!

you can set a config var to automate this for all new levels

Rama

Thanks Rama, you’re awesome.

Again, an excellent response. The only thing better than this would be if C++ supported partial classes and we could do it without inheritance.

I kind of worried that Quastion and Anwser might be misleading so heres my note to it.

Indeed there is level blueprint C++ class, but there is not equivalent of level blueprint for C++… why? Because level blueprint is a special blueprint that is saved with the level, something that you can’t replace with C++. It’s designed to contain level script, the C++ class is just there to function as base for it, you can extend it if you want with events that can be called from C++ which can be useful support to communicate between AGameMode and level blueprints. As for level meta data you should use AWorldSettings instead to extend World Settings tab which is also saved with the level.

I’m saying this because there people who makes newbie mistake by treating level blueprint as a master class of the whole game code, any functions that relates the game globally, not level should be contained in AGameMode or UGameInstance (diffrence is AGameMode resets each match/level change) not level blueprint, level blueprint is exclusively for level scripting

So what’s the best and cleanest way to add some level-specific code? I’m a total beginner and I want to make changes to the skybox on a per-tick base (or maybe using timers). It would be very easy with level blueprint I guess, but if I want to use code exclusively?

Sorry, if this has already been answered in the links. I’m learning all kinds of basics atm and don’t really want to know anything in too much depth yet :slight_smile:

Make skybox class that rotates sky on tick, so you can reuse that in evert level you like. Level Blueprint is level scripting, that scripts the level

#Yes. The equivalent is already built into the engine.

It’s hidden for some reason. If you’re looking for the C++ equivalent tick the show all classes box. Search for level and you’ll see the LevelScriptBlueprint class.

[ULevelScriptBlueprint][1]
87080-

Unfortunately the link above is dead. Use this one instead:

The key is to create a c++ class based off of the LevelScriptActor and then reparent your level blueprint to your new c++ class.

You are lifesaver my friend, thank you!

Use ALevelScriptActor to do your C++ stuff, then reparent your BP. Link is dead due to wiki changes, future users will have to start with ALevelScriptActor.

Note that GetLevelScriptActor() (from a ULevelStreamingDynamic* pointer) will return null if the level instance did not finish streaming in, and did not call MyLevelInstance->SetShouldBeLoaded(true). You will also ave to cast it to your custom ALevelScriptActor ptr.

For level instances, GetLevelScriptActor() should only be called after OnLevelShown delegate has been broadcasted. (Bind your own method to it, so you can all it at the time you need to.)

For your custom level script actor, be sure denote BlueprintNativeEvent functions with the _Implementation postfix.

Use ALevelScriptActor to do your C++ stuff, then reparent your BP. Link is dead due to wiki changes, future users will have to start with ALevelScriptActor.

Note that GetLevelScriptActor() (from a ULevelStreamingDynamic* pointer) will return null if the level instance did not finish streaming in, and did not call MyLevelInstance->SetShouldBeLoaded(true). You will also ave to cast it to your custom ALevelScriptActor ptr.

For level instances, GetLevelScriptActor() should only be called after OnLevelShown delegate has been broadcasted. (Bind your own method to it, so you can all it at the time you need to.)

For your custom level script actor, be sure denote BlueprintNativeEvent functions with the _Implementation postfix.