Can anyone point me to where I can learn how to send players from one Scene to another Scene?
I was able to get a player to enter a portal and go to another scene, but the exited out at 0,0 I believe. How would I control where I want them to drop in the ‘exit’ scene?
I’m the coder for the caveman artist above… what I’m currently doing is taking the ‘portal’ and attaching a loadlevel to it which works. The problem is the character isn’t ‘spawning’ in the new location… I can see the new scene but it’s not playable. No character / player actually ‘spawns’. You just get a view from the main camera. I tried attaching the below to the main camera but it’s not doing anything. I’m very new to unity if you haven’t guessed :).
You either need to make sure your player doesn’t get destroyed when changing scenes or you’ll need to instantiate the player again. Have a look here for DontDestroyOnLoad:
Scene’s in Unity are entirely independent from each other - when you load a new scene, everything form the old scene is effectively destroyed. You either need a copy of your player in every Scene, or you need to make it so the player object persistent across all scenes using DontDestroyOnLoad.
It’s probably worth looking into this anyway, since at some point you may want to have some form of GameController or Manager object to help with non-level related game states.
I just thought of another question. I’m reading up on this but I’m confused as to where I put that function. Do I put it on the new level or put it on my character or?
Put it on your player. Add a Script Component to your player and make sure that code is in it. Or, just add it to a script component that already exists on your player. Be careful though, because if it’s a script that’s also attached to other objects, those objects won’t get cleaned up either. I’d recommend putting it on a script that’s ONLY applied to your main character.
Well I thought I was doing OK but it’s still not working. Parts of the previous screen show up now as it should but my character isn’t being spawned. I attached the below script to my character. The picture is what I end up with when I change to the scene with no 3rd person controller/character. I’m wondering if he is somehow showing up in the wrong place? The view seems to be from the main camera and not the camera from the previous scene.
Thanks for any help! Noob questions!
using UnityEngine;
using System.Collections;
public class DontDestroy : MonoBehaviour {
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);