void Start() { col = GetComponent <Collider>(); camRig = GameObject.FindGameObjectWithTag("Player").GetComponent <OVRCameraRig>(); gun = camRig.GetComponentInChildren <Gun>(); input = GetComponent <IInput>(); }
protected EasingFunction.Function easingFunction; // cached at every execute override public void Execute(string eventName) { if (what == null) { what = eventSource; } if (targetRotation == null) { targetRotation = transform; } rbToMove = what.GetComponent <Rigidbody>(); camRig = what.GetComponentInChildren <OVRCameraRig>(); easingFunction = EasingFunction.GetEasingFunction(easing); startRotation = what.transform.rotation; endRotation = targetRotation.rotation; if (camRig != null) { startRigRotation = Quaternion.Euler(OVRManager.instance.headPoseRelativeOffsetRotation); Quaternion startCamRotation = camRig.GetComponentInChildren <Camera>().transform.rotation; startRotation = camRig.GetComponentInChildren <Camera>().transform.rotation; Quaternion diff = targetRotation.rotation * Quaternion.Inverse(startCamRotation); Quaternion diff2 = Quaternion.Inverse(startCamRotation) * targetRotation.rotation; endRotation = diff * startRotation; } // direct test OVRManager.instance.headPoseRelativeOffsetRotation = Vector3.zero; what.transform.rotation = endRotation; //return; //startTime = Time.time; // Apply immediately /*if (duration < 0.00001f) * { * ApplyProgress(1); * }*/ }
private void Start() { // Get Camera Rig camRig = FindObjectOfType <OVRCameraRig>(); cam = camRig.GetComponentInChildren <Camera>(false).gameObject; rbCam = cam.GetComponent <Rigidbody>(); if (rbCam == null) { rbCam = cam.AddComponent <Rigidbody>(); rbCam.isKinematic = true; } }
// Use this for initialization void Start() { string jsonPath = Path.Combine(Application.streamingAssetsPath, mapJsonFile); print(jsonPath); if (File.Exists(jsonPath)) { // Read the json from the file into a string string dataAsJson = File.ReadAllText(jsonPath); // Pass the json to JsonUtility, and tell it to create a GameData object from it mapData = JsonUtility.FromJson <Map>(dataAsJson); } else { print("error on reading json file"); } Room prevRoom = Instantiate(startRoom, level); // instantiate player OVRCameraRig player = Instantiate(playerPrefab, playerSpawn.position, playerSpawn.rotation); ArcTeleporter teleporter = Instantiate(teleporterPrefab); teleporter.objectToMove = player.transform; teleporter.GetComponent <TallRaycaster>().trackingSpace = player.GetComponentInChildren <Transform>(); // generate rooms for (int i = 0; i < mapData.rooms.Length; i++) { // room type is middle room unless this is last room Room roomType = (i == mapData.rooms.Length - 1) ? endRoom : middleRoom; RoomContent rc = mapData.rooms[i]; Room currentRoom = Instantiate(roomType, level); // get the previous exit and this entrance Transform prevExit = prevRoom.exits[prevRoom.exits.Length - 1]; Transform roomEntrance = currentRoom.exits[0]; // calculate world offset based on previous exit currentRoom.transform.rotation = new Quaternion(roomEntrance.rotation.x - prevExit.rotation.x, roomEntrance.rotation.y - (prevExit.rotation.y + 180), roomEntrance.rotation.z - prevExit.rotation.z, roomEntrance.rotation.w - prevExit.rotation.w); currentRoom.transform.position = prevExit.position - currentRoom.transform.rotation * roomEntrance.localPosition; //room is created, fill with content for (int j = 0; j < rc.imagePaths.Length && j < currentRoom.paintingSpawns.Length; j++) { Texture2D texture = loadImage(new Vector2(100, 100), Path.Combine(Application.streamingAssetsPath, rc.imagePaths[j])); GameObject prefab = Instantiate(paintingPrefab, currentRoom.paintingSpawns[j].position, currentRoom.paintingSpawns[j].rotation); prefab.GetComponent <Renderer>().material.mainTexture = texture; } currentRoom.SetAudio(rc.audioPath); GameObject tmp = Instantiate(textMeshPro, currentRoom.textSpawn.position, currentRoom.textSpawn.rotation); tmp.GetComponent <TMPro.TextMeshPro>().text = rc.text; // instanstiate room prevRoom = currentRoom; } }