How can we transition from one level to another in a side scroll runner without loading a new scene.
The method that I’m using is:
-
Edit the game object in the editor (move, scale, rotate) whatever.
-
Press apply to the gameObject to reflect the changes to the prefab
-
Then disable the gameobject
-
My ResourceManager.cs will do the work and instantiate a copy of the gameobject at runtime when I want (maybe it will generate a problem related with gameObject references).
My question is there a better way to solve this issue? I’m trying to not overuse memory.
The bad thing is that I have a lot of gameObjects for one level. I think that should be a faster and better way to do it.
Funny thing is that I’m actually doing something very similar in my current project. I will tell you right now that from my tests and findings, using Instantiate to load Prefabs causes a significant game freeze for a split second that is very noticeable (at least on mobile, I’m testing on Android at the moment).
I am now trying to convert my system to a pooling system. Basically it was load a couple of each type of prefab when the game first starts and deactivate them until needed. Once one is needed, it will reactivate and move it into the correct spot. Once that prefab instance goes off-screen I deactivate it again.
Mmmmm… yes I could have all objects here (level0, level1, … leveln) and only activate the ones that I need but, I think this is a bad approach because it will be a lot of Inactive GameObjects taking memory.
The way i would like to do it when changing to level0 to level1 was like “removing all objects from level0” instantiating all objects from level1.
I still thinking the best way to do it.
Thanks for your answer.