- Home /
Loading into a scene at GameObject
how do i make it so i load into the scene and at a GameObject. In the script i only load to scene but i want to be able to load in to different areas in the scene from other scenes.
#pragma strict
var NewScene : String;
function OnTriggerEnter(Col : Collider)
{
if(Col.tag ==("Player"))
{
Application.LoadLevel("DarkTown");
}
}
have you add your current scene and the scene that you want to load in the build settings ?
you don't need the brackets between "Player". I think that what prevents you from loading if You already add your scenes into build settings
Answer by Cuttlas-U · Apr 08, 2017 at 10:55 AM
Hi ; I think u can do that with PlayerPrefs;
for example if u have 3 doors in the first Scene change the name of the doors to "0" , "1" , "2";
then before u load the next set the name of the door as an int to prefs like this :
PlayerPrefs.SetInt("door entered ", int.Parse(door.gameObject.name));
then when u go to next scene create a manager that in the Start() method get this pref and based on the number change your position in a special area :
switch (PlayerPrefs.GetInt("door entered "))
{
case 0:
player.transform.position = new Vector3(1, 1, 1);
break;
case 1
player.transform.position = new Vector3(2, 2, 2);
break;
case 2
player.transform.position = new Vector3(3, 3, 3);
break;
}