[Solved] How to change layout?

Hello all,
I created a platform game. I designed the first level in layout named “level1”
At the and of the first level, I want do remove the layout 1 and load the layout 2.

I use “Create object from an external layout: layout2” but it seems that the layout one is not unload so I see two layout in the same time.

Can you please help me to “unload” the first level ?

If you want to re-use the same scene only want to load a different layout, you need to restart the level to clear the layout from it.

So what I would do is store the level number in a global variable, let’s call it “Level” and the default value is 1 that you can set in the global variable editor in the game settings.

And then in the scene add the event:
At the beginning of the scene : Create objects from the external layout named: "layout" + ToString(GlobalVariable(Level))

Then, when the level is complete only increase the value of the global variable Level by 1 before reloading the level:

Do + 1 to Global variable Level
Change to scene "scene_name"

Where “scene_name” is the name of the current scene, the same scene.
You can also use an expression if you prefer to get the name of the current scene.

Change to scene CurrentSceneName()

This way, once the player completed the level and you reload the current scene, it should load the objects from the next layout automatically.

Delete all the objects of a group?

It works perfectly. Thanks !!!

1 Like

Thanks for your answar, but I prefer do not delete all the object.

1 Like