About a week ago now, I was tasked to create a Skyrim functioning door system, where you could give the script the player object, a new scene, and an object name, and it load the new level without destroying the character, find the object via its name and send the player to that objects transform, I think I am about half way there, but not sure.
As I am a 3D artist, I had to do my best with the limited scripting knowledge I had.
Can anyone help me complete this? All help is hugely appreciated.
P.S. For anyone who manages to get this working how I need it to, will get a date driven event system for stuff like timed Christmas, New Years and Easter objects, if they want it.
#pragma strict
var PlayerCharacter : Transform;
var SpawnPoint : String = "";
private var drawGUI = false;
var Spawner : Vector3;
var NewScene : String = "";
var toText : String = "";
function Update ()
{
if (drawGUI == true && Input.GetKeyDown(KeyCode.F))
{
LoadNewScene();
}
}
function OnTriggerEnter (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = true;
}
}
function LoadNewScene ()
{
DontDestroyOnLoad(PlayerCharacter);
Application.LoadLevel(NewScene);
yield WaitForSeconds (0.2);
Spawner = GameObject.Find(SpawnPoint).transform.position;
//Vector3 position = Spawner.transform;
PlayerCharacter.transform.Translate(Spawner);
}
function OnGUI()
{
if (drawGUI == true)
{
//GUI.Label (Rect (Screen.width*0.5-0, 200, 120, 22), "Press F to open to");
//GUI.Label (Rect (Screen.width*0.5-35, 220, 150, 22), toText);
//GUI.color = new Color(1,1,1,1.0f);
GUI.skin.box.fontSize=15;
GUI.backgroundColor = Color(0, 0, 0, 0);
GUI.BeginGroup (Rect (Screen.width / 2 - 75, Screen.height / 2 - 0, 150, 50));
GUI.Box (Rect (0,0,150,25), "Press F to open to");
GUI.Box (Rect (0,22,150,25), toText);
GUI.EndGroup ();
}
}
function OnTriggerExit (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = false;
}
}