- Home /
how to spawn and destroy
Okay I have another question to ask, and this is when the player approaches a part in the level for a section of it to load.
I want to keep all of it together in one whole level so i dont have to keep creating a seperate biuld, to just make it so that when the game starts, keep the "begining section" of the level first, but everything else will be gone till you reach like a checkpoint, or in this case a triggered gameobject, to delete "the begining section" and create "middle Section" to keep the player from lag and delay, while playing the game.
And I want to keep doing this through out the rest of the entire game. I would Love to know the script as i am a scripting noob, i will admit but not affraid to ask.
Thank you.
Check out our site!
Are you looking for a solution like the "strea$$anonymous$$g sub-levels" on Unreal Engine? I have no idea how, but there are some new keywords for you, if that's it. ;)
Answer by Cyclops · Mar 10, 2010 at 09:40 PM
On the other hand, you might not asking about streaming, so much as making areas visible as a player activates various triggers. Which is actually how I first interpreted the question, until I saw the bit about lag. If that's the case, what you can do is:
Make an empty GameObject (GO) for each zone you want, and name them (example, I'll call one Level_9). Move the objects to be in that zone, under the GO as children. Disable Level_9 in the Editor - it's the checkbox near the name in the Inspector. When it asked, you also want to disable all the children. They should no longer be visible when the level starts.
The second part, enabling them is a bit more tricky. You need a script on each triggering item, that will re-enable a specific GO and all its children. The script would be attached to some object (call one, say, Portal_9), which would set to fire on mouse-click or collider proximity. The script would have a public GameObject variable, which you set to Level_9. That gives the script a reference to the GO.
Here is a question/answer on writing a script to trigger based on object proximity:
Triggering a GUI based on Proximity.
Then, when the script fires, it has to enable Level_9 and all its children. Here is another answer which talks about how to enable a GO + children:
Enable/disable a complex GameObject?
And yes, it's going to be a fair bit of programming - welcome to Unity. :)
Answer by Cyclops · Mar 10, 2010 at 09:37 PM
There's two possible answers, depending on what you're trying to do. If you're just trying to keep the player from staring at a long loading bar, then you can do something like this:
make the first scene a really small loader scene that does a progress bar, and use a streaming web player. That way your progress bar will come up fast (even on dial-up) and you can do whatever you want in Unity to make it nifty. Well, within reason...the point is to keep the first scene really small. :)
To quote Eric5h5 from: Web Player Loading Screen
For more information, see the manual at Web Player Streaming
With this method, everything in the scene will be loaded (eventually), but it shouldn't slow down the player.