// Use this for initialization void Start() { // initialize all MazeTools MazeTool[] tools = { top, bottom, left, right, back, front }; for (int i = 0; i < tools.Length; i++) { tools[i].Start(); tools[i].gameObject.SetActive(false); } // initialize the MazeStructure mazeStruct = new MazeStructure(top, bottom, left, right, front, back, radius); cells = mazeStruct.MakeCells(cellFloor, cellWalls, cellWallTops, cellFloorMat, cellWallMat, cellWallTopMat, lightFlicker, radius); // initialize this transform.position = mazeStruct.GetStartSphere(); skyboxMaterial = Resources.Load <Material>("Overcast2 Skybox"); skyboxMaterial.SetColor("_Tint", new Color32((byte)128, (byte)128, (byte)128, (byte)128)); GetComponent <OVRCameraRig>().Init(); this.playerRigid = gameObject.AddComponent <Rigidbody> (); this.playerRigid.freezeRotation = true; Physics.gravity = Vector3.zero; SphereCollider collider = gameObject.AddComponent <SphereCollider>(); collider.material = (PhysicMaterial)Resources.Load("WallPhysics", typeof(PhysicMaterial)); collider.radius = 1.5f; collider.center = new Vector3(0, .4f, 0); // initialize other objects Vector3 keyPos = mazeStruct.FindKeySphere().normalized *(radius - 2.5f); Quaternion keyRot = Quaternion.LookRotation(Vector3.Cross(-keyPos, Vector3.one), -keyPos); key = (Key)Instantiate(key, keyPos, keyRot); cLight = ((GameObject)Instantiate(cLight.gameObject, cLight.gameObject.transform.localPosition, Quaternion.identity)).GetComponent <Light>(); lights = ((GameObject)Instantiate(lights.gameObject, new Vector3(85.4f, 100f, 100f), Quaternion.identity)).GetComponent <LightSystem>(); lamp = ((GameObject)Instantiate(lamp.gameObject, lamp.gameObject.transform.localPosition, Quaternion.identity)).GetComponent <Lamp>(); lamp.transform.rotation = Quaternion.Euler(70.7834f, 342.207f, 321.425f); lamp.gameObject.SetActive(false); lantern = GameObject.Find("Lantern"); lantern.SetActive(false); // create and initialize player and monster //print("Monster: "+monster); monster = (Monster)Instantiate(monster, new Vector3(4.79f, 47.36f, -.038f), Quaternion.identity); AudioSource src = gameObject.AddComponent <AudioSource>(); src.clip = lightsOutInit; monster.gameObject.SetActive(false); angle = Mathf.PI / 2; AudioSource src1 = gameObject.AddComponent <AudioSource>(); src1.clip = lightOff; lights.Init(mazeStruct, cells, src1); }