Should I have each level in my game be in a different scene? Would it help with performance? When I make a new scene it’s completely blank, so would I have to copy paste all of the code from my current scene over?
Personally I recommend creating a “New Scene” for each “type” of scene.
Then use a new “External Layout” for each implementation of that type of scene.
For example, I have one scene called “Level” and I have 80+ External Layouts that are the actual levels for my game. Each of those share all of the assets and logic defined in the “Level” scene, but the layouts are completely different.
You’ll have to add a little extra logic to the main scene to load the objects from an external scene. I use a global variable called “CurrentLevel” and when the Level scene starts it loads the external layout with the name stored in CurrentLevel.
BTW you can also use “External Links” in your code space to reuse all of the logic from another scene or External Event.
Check out this thread for details on how to use External Events.
Thanks, that fixes the code problem, but do I still have to copy paste over all the object types from one scene to another? Because in my second scene there are no objects or object groups currently, do I need to make copy them over every time?
Right click on the object and set it as a Global Object. Global Objects are available in every scene.
So I used a link to Scene2 so it uses the code from scene1, and it works fine when I start in the second scene, but when I go to the second scene via command none of the code works. Is it because scene1 isn’t loaded anymore? How would I fix this?
Instead of creating a new scene use an ExternalLayout so you can reuse the resources and logic from your first scene.
Then you don’t even need to use a link to the logic in the main scene, just change the logic there to load the layout of the resources from the appropriate ExternalLayout. If you have already laid out specific scene elements in the main scene, then cut them and paste them into a new extnernal layout. Leave all of the shared layout things like the GUI elements in the scene, and everything else goes into the external layouts.