// Update is called once per frame void Update() { if (Input.touches.Length == 2) { Application.LoadLevel(1); } if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if (Player.GetComponent <Player>().GameStarted) { if (touch.phase == TouchPhase.Began && //Check If Left side of screen is pressed and turn camera left if true LeftTouch.HitTest(touch.position)) { if (this.GetComponent <CameraSwing>().cardinalAngles()) { this.GetComponent <CameraSwing>().toLeft = true; } } if (touch.phase == TouchPhase.Began && RightTouch.HitTest(touch.position)) { if (this.GetComponent <CameraSwing>().cardinalAngles()) { this.GetComponent <CameraSwing>().toRight = true; } } } if (!Player.GetComponent <Player>().GameStarted) { if (touch.phase == TouchPhase.Began) { Player.GetComponent <Player>().GameStarted = true; } } } } }
public static bool Zoom(this View v, Camera c) { bool success = true; float targetZoom = 1; float speed = 1; Transform playerTransform = GameObject.Find("/Player").transform; Vector3 pos = c.transform.position; Quaternion rot = c.transform.rotation; switch (v) { case View.THIRD: targetZoom = -3; pos.y = playerTransform.position.y + 5; pos.z = -5; rot.x = 35; RightTouch.print("New " + c.name + " camera position: " + pos); break; case View.LONG: targetZoom = -6; pos.y = playerTransform.position.y + 8; pos.z = -10; rot.x = 40; RightTouch.print("New " + c.name + " camera position: " + pos); break; case View.FIRST: default: pos.y = playerTransform.position.y; pos.z = playerTransform.position.z; rot.x = playerTransform.rotation.x; RightTouch.print("New " + c.name + " camera position: " + pos); break; } c.transform.position = pos; c.transform.rotation = rot; //Camera.current.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, targetZoom, Time.deltaTime * speed); return(success); }