Editting a external event

Hello,

Is it possible to use external events for different levels? Because look of each level is different from each other. If so, then how can I edit event of an external event(Conditions and events)? External event doesn’t come with it’s own event sheet. I would like to edit certain aspects of this external event.

I could use scene to change levels, but for this I am having to use multiple copies of level 1 which makes everything cumbersome.

Thanks in advance experts…!!

Hey i think i dont understand your question?

Are you asking if you can change an external event on the fly ingame?
If yes no you cant if you want an external event for level 1 and one for level 2 you can just copy things over from external event 1 and change the things you need.

Tho personally i would use external events for stuff that you constantly need to use like player mechanics,enemy AI,UI stuff and have specific stuff that only make sense in that level in the scenes event sheet like code for different puzzles for example.

I hope i could help you with your question but if not please be sure to explain your problem in more detail and maybe with also photos of your problem.

Hi its unclear exactly what you mean but what i think you mean is can you use external events but makes elements of them specific to different levels?
You can use a global variable like ‘currentlevel’
and then within the external events linked to an enemy for example have something like
currentlevel=3 and have events linked to the enemy being able to fly and change animation+10 to get it to a new set of animations etc

Yes. You link the external event in the scene’s event sheet. To get this, right click on the “Add a new event” text in the scene’s events:


Effectively GDevelop takes the external events and insert them at the point of the 'Link external event' action. The external events can be linked in any scene events, event in multiple places.

However, if you refer to objects or variables that aren’t available in the scene, then an error will occur or the event with the unavailable object or variable is ignored.


External events are events sheets. They don’t have a layout like a scene. However, an external event needs a scene associated with it, so GDevelop knows what variables and objects are available in the external event.

1 Like

Hello, all thanks for the response.

Sorry, I messed up the question. I was asking about external layouts. Every scene has an event to control that scene, events with conditions and actions. But it seems external layouts doesn’t have such events linked to it. I have a level 1 scene, but if I want to make level 2 with same codes, do I have to duplicate level 1 scene? It makes multiple codes for each level. It would be better if I stay in one scene and use external layouts for levels. But external layout has a scene 1920x1080 where I can design the things however I like but can’t code that layout exclusively. I just want an event that controls the external layout.

Again sorry for the confusion earlier. Hope I was able to explain this time.
Thanks

Hi you can refer to the external layout with a number variable eg ‘level’
and your layouts are named “1” “2” etc
and use one scene and generate objects from external layout “level”.
if that’s what you mean - so in this game there’s a number var player.currentlevel and just one scene - so you don’t need to duplicate the scene

1 Like

Hi,

This seems more like what I want. Let’s say level 1 has 2d physics gravity 1, and certain player maneuver capabilities (force 10 to all directions)
And level 2 has gravity .5 and player movements (force 15 to all directions). This kind of setup is easy with different scenes and it’s own events. But I am struggling with external layouts. I am not sure how to link an event to an external layout. Could you please provide the example you have created above or please guide me to a YouTube link on how to do the same?

My scenario
Level 1 : clouds and sky( main scene) and has it’s event which controls player capabilities and gravity.
Level 2 : space setup (external layout) with different player capabilities and different gravity among other changes.
I was able to design the level 2 using an external layout, but was unable to give properties unique to this level.

Thanks

If you want different parameters for physics on each you would either use a load of if statements at the beginning of the level scene (player.currentlevel=3 then set gravity to ?) or use a global array.structure containing the parameters.
eg levelsettings[player.currentlevel].gravity and set these up at the beginning of the scene.
generate objects from the external layouts from player.currentlevel at 0,0 on base layer
you need to refer to the objects in the next event if you want to hide any etc

External layouts work best for projects where the levels are extremely similar. They’re perfect for tracks for racing games or puzzle pieces for say a jigsaw puzzle.

If your levels are really similar then use external layouts. If the levels are too different then it might be easier to use different scenes. You probably wouldn’t mix a racing game and jigsaw puzzle in the same scene using layouts. It would easier to have something like that in different scenes.

You could still reuse events with different scenes. You could use external events, behaviors (built-in or custom) or other extensions. That would keep the main event sheet events to a minimum.

Now, if things were really similar then you can make changes to things like variables and other settings with a bunch of events after the layout is added.

You can add a layout from a list or as an expression.

Add layout “Level” + ToString(CurrentLevel)
CurrentLevel = 1
… Set gravity to 1.5
CurrentLevel = 2
… Set gravity to .5

Now, you could also add object variables that could hold certain settings. The default values can’t be different but you can edit the instances and change their values. So, when the layout was added, you could get the setting from it. You could even include dummy objects just to hold settings and then delete them.

Add layout “Level” + ToString(CurrentLevel)
Set gravity to Player.GravityVariable

You could also save settings in a scene array or an array of structures if there are several settings.

Add layout “Level” + ToString(CurrentLevel)
Set gravity to Settings.Gravity[CurrentLevel]

Remember, adding layouts are different than adding objects. For some reason layout objects aren’t automatically picked when they’re added. So, if there are already instances of an object in a scene then any events would apply to both the new and old objects. You can use object variables to track if an object was previously added.

Also, it’s best not to add subevents to the line that adds layouts because objects don’t always get added instantly. Sometimes, they’re not added until the next event. The same is true with deleting objects. They’re not deleted immediately.

Instead of

Start was clicked
… Delete layout objects
… … Add layout
… … … Set player opacity to 128

Use

Start was clicked
… Delete layout objects
… Add layout
… Set player opacity to 128

Thank you so much for the detailed explanations,
The issue is I have a main level scene and 15 events for 15 enemies and their powers and such. These events are linked with this main level scene. So if I duplicate this main level, all the objects I used also will be duplicated which will be dedicated to that scene. So let’s say for 10 levels and 15 enemy events, it will be so difficult to maintain everything because of the duplications.

I am not sure how to tackle this.

Thanks

I’m not following your description. Do you want to use 1 scene or multiple scenes? For multiple scenes with the same objects, you can use global objects. Maybe I misunderstood things.

For multiple enemies, you might be able to simplify the events. Maybe put them in a group.

Whether you use 1 scene or multiple, the events can be in the main event sheet, external ones or functions or behaviors.

Dublicating a scene is best avoided really. It causes problems if you want to turn an object into a global object and if you decide to change a bit of code you need to do it on all of them. It’s better to think about which objects you want as global objects and which sections of the events you want as external events and can elements like ui and background be created as external layouts

2 Likes

Hi,
I will have to duplicate main scene(level 1) with lots of codes and controls, which will be 10 duplications for each level. Will be difficult to manage each scene. Mainly I will be changing BG, physics like gravity and dampening etc for each level.

Hi,

Yes I tried duplicating level 1 and it’s really tedious and confusing like you said. But do you think there is another way? I am unable to find a different method. There is a variable which increase pace of the game for this level(like temple run). Then I will have to save or store this information. Player will hit a door which will take the player to a random level. And there also player will start from pace 1 of the game gradually increasing the pace of that level with different bg, enemies and physics etc, save these before hitting another door and load these values on return etc.

This is one way …it’s not right for all situations …it’s an example


So you don’t duplicate you include external data.
Here World 1 and World 2 could be just objects on game scene 1 and game scene 2 but this way you could re use World 1 on scene 6 for example.
The objects that are used on all the scenes - make them global.

2 Likes

Thank you so much for taking time to draw the explanation. It makes a lot of sense to me. I will definitely work on it. Much gratitude…!!!

Thanks

Thank you so much for your explanations, it helped me learn a lot. Appreciate it.

1 Like