Character spawn Issue.

I think this belongs here…

Anyway, i’ll keep it short. I’ve set up an area in the games first level that allows me to travel into the second level just by colliding (an opening to a cave) Simple. It works the other way, but Since it’s loading the first level again, the natural spawning point is obviously at the wrong place. When he leaves the 2nd lvl to go back to the first lvl, i’d like to just be right outside the cave. Instead, it spawns me back where the game starts.

I understand why it does this, But i’m wondering… How do I get the character to spawn outside the door when going back to level 1 from level 2 without having to create a whole other instance of level 1? and without having to set the default spawn point at the cave door. While that would solve the problem, it’s only a temporary fix to a much larger issue in the long run. I can’t do that for the rest of the game.

Make sense?

You can make an object persist between scenes using Object.DontDestroyOnLoad. Basically, you should create a class that contains a number or string to represent which scene the player has come from after emerging from a portal. Make an object of this class in the startup scene and call DontDestroyOnLoad on it. Then, when you leave a scene through a portal, store the name of the scene in the object. When the new scene starts, you will be able to determine where the player has come from and move it to the correct spawn point.

Hi Andee,

I’m actually having the same problem. What do you mean to store the name of the scene in the object?

Thanks in advance.
-Hakimo

The issue here is that when you jump from one scene to another, there is no direct way to know which scene you have come from. You may have different “portals” in the game and be able to travel from one scene to several different ones. This means that you can’t just start the player off from the initial position when you re-enter a scene - you have to know which scene you have come from so you know which portal is the one where the player should enter.

The easiest way to go is to use a variable to remember the old scene just before calling LoadLevel to activate the portal jump. Then, when you enter the new scene, you know where you have come from. One way to do this is to use the DontDestroyOnLoad technique described above. Another is to add a static variable to a script somewhere and store the level name there.

Hello andeee,

Sorry to barge in this topic like this. If you could andeee, please take a look at what I’ve done and maybe can help a bit.

You can go here:
http://forum.unity3d.com/threads/76109-HELP-Respawn-point.