Should i make objects global or copy scenes manually?

Hi, i am working on game with many levels and i have lots of objects(about 200). if i am going to use same object in 20% of levels(10 scene) should i make it global or manually copy each scene.

One factor you take into account to decide if you should or should not IS

Imagine you have enemies but on one levels they move faster on other slower
On one level they have more HP on other less
On one level they have a lot of more random movement
On other they patrol just from left to right or are idle

And this is that factor
If they are doing exact same thing in all levels
No reason to copy paste them but just make them global
But if they have different attributes per scene or different behaviors then you would at least consider keeping them per scene and copy them over to other one so you can adjust them at will
Of course most of the crap even if defined in behavior can be adjusted via events
But sometimes you just want to have actual separation

So general rule
They are same on all levels make them global
You need to adjust them per level then keeping them as scene object and copy them over can be better idea


Another option is just to make all of your levels in one scene. That way, if you need to change your core game logic you don’t have to update all the copies of your original level. (although that might be less of a problem if you just link most of your core logic using external events).

For some games, you can draw all your levels on one big scene and use events and the camera to activate one part of it at a time. Another way is to use external layouts to load your levels into the scene.

I normally end up using one scene as my main “game” scene, then I use other scenes just for title screen, credits, tutorial text, or things that work differently from the main game like pause menu or inventory menu.

When you suggest that
Be sure to warn users how adding objects to your scene impact performance

Actually i was asking for performance perspective, like if you keep amount of objects in scene low(instead of loading all sprites as global) does it run faster when compared unused 100 global objects, i dont mind copying everything if it will improve performance and keeping same size because its used same resources.

Did you ever seen that progress bar filling up when your game starts?

Wanna guess what it is actually loading up?
And then ask yourself why you have no such progress bar when switching scenes or any kind of delay

1 Like

intresting, i didnt think it like this, its instantly changing scene. i just worried because engine warns you to not make it global if you are not using very much and i consider making almost everything global and it might be too late to change back. Thanks for the answer.

It warns you not for performance reasons most likely
As you deduced it loads everything on game start and not before scene change

And warning is most likely so you do not make your enemies for example global and then jump around how to make them per scene with different stats
Or different animations
Same with buildings or items or whatever else you can think of

Maybe there is some performance reason to it that i do not know about
But i doubt it

1 Like