Hello, I thought that this might probably be the most common problem with fresh Unity users, so I’ve been looking for the whole day in here and found some bits. However it’s hard to put them together and make them work.
So it would be great if anyone could help me out and hopefully this will help others with a similar problem as well.
Let me start with how my level is structured.
I have 1 main scene (like a hub) and 5 small scenes (interiors) which are accessed through doors in different locations on the main scene.
Then I have an invisible box collider in front of these doors. When the PC collides with that box a text of the location behind the door in displayed in the corner of the screen and when the player hits “e” the new scene is loaded.
Here is my code for that:
var LocText: Texture2D;
var locRec: Rect = Rect (0, 0, 0, 0);
var locName =0;
function OnTriggerStay (newLevel : Collider)
{
locRec = Rect (0,(Screen.height/2) + (Screen.height/5), Screen.width/2.5, Screen.height/6);
if (newLevel.gameObject.name == “PC”)
{
locName =1;
if (Input.GetKeyDown(“e”))
{
locName = 0;
Application.LoadLevel (“Dock_Arms”);
}
}
}
function OnTriggerExit (newLevel : Collider)
{
locName =0;
}
function OnGUI ()
{
if (locName)
{
GUI.DrawTexture(locRec, LocText);
}
}
I ended up with copying the main scene 5 times and set the character in front of the correct door in each scene.
So when the player exits interior 1 a main scene is loaded where the PC stands next to the door leading to interior 1 and so on.
It works but that’s not how it should be done.
What I want is to have one main scene.
What I need to know is how can I:
-Keep character coordinates on the main scene when entering an interior.
-Add rotation to these coordinates so that when I exit the interior, the door is behind PC’s back.
-Set a start location in the new scene for the PC to appear.
-Not loose data on the quest progress. So that the NPC know that I’ve talked to them after going to another scene and back.
-Keep items. If I take a key item from one scene, it wont be there any more after returning to that place from another scene.
So that’s what I’m struggling with, hope to hear from someone!
Thanks in advance!