The following script is supposed to a) look at the last level loaded. b) spawn the player to a game object position in the new scene/level loaded.
I am failing to integrate it properly. I am new to scripting. I have tried to integrate the Awake() function but failed. I suspect this is the trouble? Code/syntax help appreciated.
I have set the var character1 and fromThisLevel on the game object/spawn point with script attached.
The new level is loading with a grey screen and no player instantiated.
I was grueling over the exact same problem, and JUST thought of this- It's working out for me, I hope it helps you too-
The problem is that we want to begin at one of any specific points. We were looking at it in a dead end way though. When you load a level, you usually have one spawn point with code to 'JUST START HERE'. We need be able to carry on info from the last level to tell the new level that you want to start at ANY specific point you specify.
I think Bunny83 just descirbed this but I don't understand all that :p...
I thought this could be done with a kind of scoring method that all spawn points could look at. This could done in a much simpler way, so fix it up how you want
Make 3 (or however many) spawn points you want in your levels and tag them startpoint1, startpoint2, etc, and add something like this to them ( I used empty game objects)
Have the actual 'teleporting game object' (a door, a floor pad, something) and add a collider set as a trigger and add this
on the player's script add this in the update function
and add at the top of the script
Do you get the set up? When you hit the exit or 'teleporting game object', you set the players teleporter number to the specifically numbered spawn point you set in the new level.
You'll have to make multiple application.Loadlevel scripts to set the specific numbers, but it works in the long run.
If you want a continuous level like in Halflife where when you enter the end-of-level trigger it loads a new level around you. The two levels are overlapping a bit so that after the loading it looks like you're still in the same level at the same position. There are even levels that have multiple transition points like you mentioned. In Halflife they use "info_landmark" nodes inside the levels to match up the two levels.
The player object should not be deleted in this case and don't need to be instantiated again. Just be sure to mark the player object with DontDestroyOnLoad.
That's how a landmark node script could look like:
On the end-of-level trigger:
and inside your gamelogic :
answered Feb 01 '11 at 05:36 PM
look in the Lerpz tutorial, it has a script in it that if Lerpz falls off the platform and hits a collision detection, he disappears and re-spawns on a platform he previously stored his location to. That script can be converted to do what you want. There are as many spawn locations in the level as you place. I placed like 3, and they worked, I then placed about 10 more and they all worked.
answered Oct 12 '10 at 03:10 AM