Create a scene at runtime

Hi,

I’m working on a project where I will need to create scene at runtime.

Is there a way to create a scene at runtime, and add all the component that I need, or I should have an empty scene and add all the component in it ?

I am using UE 5.1

Hey there @Mumchina! Welcome to the community! Are you trying to procedurally generate portions of a level at runtime? If you’re trying to procedurally generate a level, I’ve got a couple resources depending on the type of generation you’re looking for! Let me know if you need any specifics!

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

Basic Object Proc-Generation:

Procedural Mesh Generation:

What I want to do is the following
I have a mesh of a terrain surface.
Let say that from a main opening scene, the user will be provided a list, an from the selected item, I would load a scene where I want to display that mesh and having some other option to spwan some actors.

Also, those mesh will be imported at run time.

So maybe I just need to have any scene an spawn the actor I need where I need it.
Sorry if it’s not clear, I’m not used to UE.

No worries! If these maps are already created meshes, from what it sounds like, you’re trying to make something more akin to making a stage selector with some settings for spawning some actors. Most procedural generation tutorials will show off what’s necessary for spawning in the actors and setting up the level, but not the integration with the UI you’re looking for in this case.

The hardest portion of what you need is importing meshes at runtime. Natively FBX files (or any assets really) need to be turned into asset files and then handled by Unreal. Ways around this includes plugins to import meshes at runtime or a system built into the game to generate those meshes at runtime. Depending on your choice I have a (non epic affiliated) plugin I’ve seen used often for asynchronous loading of meshes.

Marketplace (paid):

If you’d like to look at the source for one of these types of plugins, this one is updated up to UE5EA, might not take too much tweaking to update for recent versions:

Then from a high level all you really need to do is import your mesh using some method, set it as your level geometry in your game instance, in the UI select your other actors, when you do pass that data to the game instance as well. After setup is complete, you open the empty(ish) scene and have your level ask the game instance what map it’s using and for the actor data, then apply that. Close the loading screen and voila. (I know it’s by no means that simple).

1 Like

Thank you so much!

As mention in the challenge to import meshes, I will be paring the mesh with a point cloud. So, I would also need to import Lidar point cloud at runtime.

That been said, I have some other task to do before getting there, but I wanted to open a thread in to gather information. I will update the post here when I will get to the runtime FBX import.

:slight_smile:

No problem, let me know if you have any questions on some specifics. I don’t know too much about Lidar but it’s worth looking into the plugin to see if the data can be streamed at runtime. Documentation below: