Ability to spawn unique copies of scenes, place scenes in other scenes as objects

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)

1 Like

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 :slight_smile:

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? :thinking:
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.