+1 vote

Hi everyone!
I’m making my first game in Godot and have a bit of a conundrum since I have never made a game with changing levels and have no idea how to approach it.
The game is a 2D platformer with different levels that have a static camera that covers the whole room in the viewport. The Player will be “teleporting” to other levels when he reaches exit points of each levels .
My idea was to lay out the whole game in a single scene, so I can easily edit each levels and see how does it compare to next/previous levels. But loading the whole game on runtime doesn’t seem to be a very good idea performance wise :D
So what’s the best approach to design the game and have all the levels and platforms in the same scene, but when running the game to have it individually load when enter that level.
All of the platforms are moving Kinematic Body scene’s, levels should only change their background sprite that’s animated, and the “exit points” are just going to be Area nodes with animated sprite.
If anyone has a totally different way they would approach, please tell me, it’s always better to hear many different opinions :)
Here's a rough draft of how the game should look:
enter image description here

in Engine by (64 points)

1 Answer

0 votes
Best answer

Don't think of performance until you get performance problems.

Just get_tree().change_scene should be fine.

Later you can preload levels on an autoloaded script or instance the levels on a node that manages the levels.

But as a first step, I suggest to make the quickest way which is changing scenes (faster to test levels too).

by (7,922 points)
selected by

My idea was not actually "change scenes" per se, but to layout all my Levels in a single Scene, in which I would just teleport Player from one exit point to an enter point for the next Level.
As pictured above, all of the levels will visible in the Main Scene of the entire game and the Player will be a child of that Main Scene, and so will the other Levels.

Main Scene

This way, at least I think, would be much quicker to test out Levels and a more visual way to see how they compliment each other.
But I don't think having hundreds of objects from the entire game, running their code every single frame would be a good idea for performance :D
Is there a way to load all objects from a Level only when needed (when player reaches them)?
Or maybe this approach is a bad one, I don't know... thoughts?

You can have a list of levels (paths) on an array, and load them when needed, for small things it should be fast (or instance+add current, preload the next).

Also, instanced scenes can be changed into "InstancePlaceholder" (check instanced menu) and instance them when needed.

For styles more metroidvania, your "entry/exit points" can have a reference to the next level and load/preload them on ready, once loaded, the instancing+adding is nearly immediate.

If each level is huge, the level structure may need some extra partitioning, like preloading entry points first and doing background loading of the rest while playing, also freeing old level data in chunks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.