[Solved] Why does my one instant on the scene turn into two instants?

Hi,

This is my leve_1 image:

When I run the game, two instances of the ball appear.

You can see the base scene events below:

I couldn’t find my answer in the AI chatbot.

Regards,

I would assume both your BaseScene and Level_1 have ball object placed on scene
Where only one should

The base scene doesn’t have anyone, yet I see two instances listed in the instant list for level 1. However, I only see one visible instance!

From instances panel you can select each
Check if they overlap but that is just for you to know
Where you simply should delete one

Are you previewing the scene with the layout tab having the focus? If so, you can either preview it from a scene tab or set the preview scene by clicking the arrow near the preview button.


2 Likes

Yes, this works for me.
Why was I seeing two instances earlier?

It’s weird. When you preview from the layout, it previews the layout and then the events create another copy.

1 Like

But the new version of GDevelop doesn’t have this option.

What should I do?

What do you have open in the editor when you preview? A scene, layout or something else?

Here are the options when an external layout is in open:


And these are the preview options when a scene is open:


What options do you get? Can you screen shot them?

Hi,

You can see everything from this game:

Game Structure:

Base Scene:

Base Scene events:

Level1:

Level2:

Level2 Events:

Result after pressing the preview:

Thanks

When you preview with level_2 external layout open, the objects in that are added to the scene and the base scene events are actioned. This means Level_1 external layout is also added to the scene. Hence the duplication.

When you start the preview, do so with BaseScene open in the editor.


BTW, the loading of Level_1 and Level_2 is inconsistent. Level_1 is done via the base scene beginning of scene event. But for Level_2 , it looks like you are hoping to use Level2 external events to load it.

The problem is you need to link to Level2 external events from the BaseScene events. And this means both layouts could be loaded.

I suggest you delete all the events from Level2 external events, and change the first event in your BaseScene as follows:

  1. Add a Global Variable named CurrentLevel. Set the default value to 1:

  2. In BaseScene modify the beginning of scene event to the following - click on the “Use an expression” button to edit the layout name:
    image

This will load the correct layout for each level.

This is where things start to get unclear.
Could you clarify this section?

Do you mean I shouldn’t use any external events in the game?

External events need to be linked within other events. GDevelop effectively inserts the external event code into the events at the point of the link. If the code is secific to a level, then you want to link it in BaseScene in a subevent when the game is at level 2.

What I meant is that your Level 2 external events should be linked from BaseScene. If you do that, the objects from the Level 2 external layout will be created at the beginning of the scene. However, unless you’re reloading BaseScene for every level, the “At the beginning of the scene” condition inside the Level 2 external events won’t run as expected — it should instead be placed as a sub-event under a conditional trigger.

Something like:

1 Like

Where should we declare the “GameLevel” variable?
Is it a global variable?
Where should we increase it at each level?

Did you mean increasing it in the external event sheet for each level?

Ideally a global variable, unless you save it to storage.

When a level is completed or the next level should commence.

You can do it there, if the level completion conditions specific to each level. But if the finish conditions are the same for every level, say like reaching a flag in each level, then it can be done in the base scene.

1 Like

Does UI need its own separate layout?
Should it be integrated into the base layout instead?

Ideally it should be it’s own layer - that way you can apply effects or changes to the other layers without disrupting the UI.

Is it possible to position it within a layer of baseScene?

I followed your instructions, but the ball still instantly turns into two.