I thought about this for a bit before writing my suggestion, now that I played with the engine for over a week and understand the basics of how it works. This might be two suggestions in one as I’m thinking of two independent and unrelated features.
One limitation I ran into, particularly with my plan to create procedurally generated words where variable numbers of linked maps may exist, is the fact that scenes are fixed: You have a predefined set and can’t create unique copies of a scene at runtime which can then be modified independently and act as separate locations. This is a hindrance when for instance you spawn a random number of usable houses with the same interior but want the objects and characters in each one to be randomized, whereas if your game is multiplayer you don’t want players who enter different houses based on the same interior scene to see each other. Would it be possible to allow duplicating scenes in realtime?
And an additional request which could go hand in hand with scene instances: What about allowing a scene to be placed like an object inside another scene to act as a screen or window? This could be interesting for things like interactive monitors, where each screen is defined as its own scene but the character can walk up to and operate each copy… or act as cameras allowing you to view a room from the screen before walking through the door and entering the room yourself. A scene object could be transformed like any other object (eg: sprite) just that it renders the camera of that scene.
You can load a scene, randomize the content and store the result, to be able to load it again later, depending on this or that (e.g. previous location of the player, player name, etc.).
This would be very heavy for performance. Showing a fixed image of the scene, or a basic animation, is so much lighter.
On a side note, multiple viewports feature was attempted and aborted.
Got it. You can but it’s still one scene: If for instance you place multiple house sprites across the map and want players to be able to enter any house using the same base scene for interiors, ensuring each house acts as an unique location gets very tricky: Your only bet is to store the removed contents of each house in a list, then hide the proper items each time you enter a particular house resetting the list per exit… but multiple players who can simultaneously enter multiple houses would be an unsolvable issue. So either you have a maximum number of allowed houses and each one links to one of the predefined scenes, or one large interior scene where each interior is placed per house but that’s hard since you can’t easily define a pattern containing multiple objects and spawn a set of rooms at a location.
That’s another little feature I wanted to suggest: Having some way to define a group of multiple objects placed at various positions in relation to each other, then spawn the whole thing at a fixed location. Currently you can only spawn one object… it can contain a behavior spawning other objects in relation to itself, such as by using points which is super handy… it gets complicated for large and complex items though, as you can’t visualize the group and manually move or configure each object in the template.
Multiple viewports would have been nice as an option, even with a warning that performance may be slow, but I see there the code would need to be remade from scratch… it’s not a high priority anyway just a curiosity if it was a possible design choice. On the plus side I understand iframes are supported and I can place simple HTML websites in maps if I feel I should try that for any reason?
Hmm… based on how you’ve described this, both of these questions/ideas are actually what External Layouts are for. You configure the objects you want in an external layout, add the objects to an object group named for that layout (so you can address all of them at once via an event if needed), and then spawn the objects at the location you want via the create objects from external layout event.
For the high level suggestion, the big thing to remember: Scenes are volatile at runtime (they do not store information if reloaded or changed, excluding for a single scene if it was paused). As far as I know this is by design.
Even if you could load scenes as objects, switching to other scenes and then switching back would wipe all of the info, so you’d have to generate it again. Even if you could load other scenes, you’re still going to need to track placement/positions/etc in a global variable for the information to persist between scenes, and then generate said placement again based off that data once you reload the original scene. (Unless you’re only ever switching between two scenes, then you can just use “Pause and change scenes” and “Go back to previous scene”)
You might look at the “Sprite Snapshot” extension. You can take a snapshot of an entire scene and render it to a sprite with that, although I don’t know if you can cross scenes with it (and note that size limits of 2000x2000 would still apply)
Awesome: Sprite snapshot looks like it should do exactly what I was thinking of there! This is indeed better as a separate function and I’m glad one exists now.
I looked at external layouts but was left with the impression they’re more like global layers for HUD elements. Taking another look at the “create objects from external layout” action they can indeed work as groups / prefabs: Doesn’t seem like anything prevents spawning copies of buildings and rooms with physics / collisions and everything else working! So a group feature already exists in this form
My trick will likely be to design interiors so they’re as large as the sprite of the building, then whenever a building is placed in the outdoor scene an external layout containing its interior is placed at the same position in the indoor scene, which can be known between scenes by adding each position to a global array variable. Though one question remains in that case: How do I know which scene executes first, so one first sets an array then the other uses it to spawn things at position… do scenes run alphabetical order or is there a list I can sort my scenes in?
What would make it unsolvable?
Once you find a system that works, the number of players/houses won’t matter.
You’ll need tons of structure variables to handle everything, that’s all.
Sorry for bumping old topic, figured it’s better than creating a new one with same message.
I’m not sure how external layout can help to replace functionality of prefab (aka scene-in-another-scene). I made a short video to describe what I want to achieve in GDevelop, using After Effects compositions as an example. In the video I’m placing one scene (composition) in another and can manipulate it as one object. I can animate this instance like sprite, but it will continue updating inside.
When I want to do something similar in GDevelop now, I’m storing my elements on separated layer. To animate group of elements, I’m sticking everything to one invisible object, and then move/scale/rotate this object. To bring this group to another scene, I have to copy-paste everything. Then when I need to change logic/visuals of this group, I have to edit every copy.
How external layout helps me with this case: I can place my elements and logic in another scene, and then create (copy-paste, but automatically) them in my target scene. But if I want to transform them somehow, or animate as group of objects, I still need to find and stick them with help of new events in main scene, and repeat this process in any scene where I want to put copy of mini-scene.
Am I missing something, is there a clean way to do it without repetition and manual labor?
Add the external layout objects to a global object group, then you can target them as a group.
If I remember right, you can even use non-global groups (scene groups) so long as the group names are identical to the ones in the external layout, but that’s an extra level of complexity for no real gain.
Thank you, that helps to find them quicker.
However, sticking group to object does not seem to work. And without sticking, I’m not sure how to tween group position, since every object in the group will move to one point, not as a composition but individually.
That depends on how you’re sticking them, but generally you could instance variables of somekind on each object in the scene (adding a variable to the instance such as “stick location” and then add points with the same names on the main object they’re being stuck to, then just use an event that sticks the objects to the position of the points that match their variable.
(e.g Put ObjectB around ObjectA.PointX(ObjectB.VariableString(ID)); ObjectA.PointY(ObjectB.VariableString(ID))) or something similar.
Kinda happy this is still active, since from what I remember it remains a large limitation with the engine thus far. Each scene is unique and modifications made to it are global: If you make a house interior scene and want to randomize it for multiple homes, you can’t as changes done in one home would magically apply to any house you enter… you need to make each house interior its own scene, which works if you have a fixed / maximum number of houses albeit by needlessly duplicating data, if any number of homes can spawn randomly even that might be a problem.
So it still feels like a good idea if there was a variation of the load scene action called “load copy of scene”, where you can maybe give it an ID referencing which instance of the scene that is and creating a new one if non-existent. After all objects work the same way: Whenever you use an action to add an object, changes to say the health of that object don’t affect every instance, if it did killing a single monster would cause them all to die. Scenes working in a similar way would likely help a lot of creators.
Interesting approach, this sounds like something that should work, thanks. Though at this point it feels not much faster than manual copy-pasting objects and events; depends on amount of instances, I guess.
Still would be nice to see (and transform) a scene on canvas, much easier for visual folks to comprehend, a man can dream
Unless you’re having unique scenarios for each scene, you could just make the events an external event sheet and use it whereever you use the external layout.
Update about sticking objects from external layout. I’m relying on “Sticker” extension, because it’s much easier to use, than writing rules for position/rotation/scale (re-creating Sticker from scratch basically). Unfortunately, I didn’t find working combinations. What I tried:
Creating 2 objects (A and B) on external layout. B has Sticker on it. Then when objects are created in main scene, I tried sticking B to A, didn’t work.
Creating object B with sticker on external layout. Object A is in main scene. Sticking B (after creating) to A from main scene also didn’t work.
Thanks for getting back to this, and that’s good to hear! Will it allow actual scenes to have unique instances? The limitation I remember facing is that you can’t, for example, design a room that can be used when entering multiple houses with each room having unique furniture or characters located inside: Objects can be global and customized independently once spawned, the ideal solution indeed appears to do something similar for scenes.