private void ChangeCamState() { if (Input.GetKeyDown("1") && currentCamState == CamState.Free) { if (currentObject != null) { currentCamState = CamState.Attached; InitializeSettings(currentObject); } } else if(Input.GetKeyDown("2") && currentCamState == CamState.Attached) { currentCamState = CamState.Free; _parent.transform.rotation = Quaternion.identity; transform.rotation = Quaternion.identity; } }
private void SetState(CamState s) { state = s; }
void SetCameraToTrack() { state = CamState.TrackRocket; rocketPlayerScript.ReadyToPlay(); }
/* * Updates the position of the camera */ private void UpdatePosition() { if (Input.GetKeyDown(KeyCode.Mouse0) && camState == CamState.camMain && Time.unscaledTime - firstClickTime <= doubleClickTime && singleClick) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Physics.Raycast(ray, out hit); successfulDoubleClick = true; if (hit.collider.gameObject.tag == "Tower") { selectedTower = hit.collider.gameObject; camState = CamState.camTower; StartCoroutine("MainToTowerRoutine"); } if (hit.collider.gameObject.tag == "Fish") { if (!selectedFish) { selectedFish = hit.collider.gameObject; selectedFish.GetComponent <Fish>().isSelectedFish = true; } else { selectedFish.GetComponent <Fish>().isSelectedFish = false; selectedFish = hit.collider.gameObject; selectedFish.GetComponent <Fish>().isSelectedFish = true; } camState = CamState.camFish; StartCoroutine("MainToFishRoutine"); } } if (Input.GetKeyDown(KeyCode.Mouse0) && camState == CamState.camMain) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Physics.Raycast(ray, out hit); if (hit.collider != null) { if (hit.collider.gameObject.tag == "Tower" || hit.collider.gameObject.tag == "Fish") { firstClickTime = Time.unscaledTime; singleClick = true; } } } if (successfulDoubleClick) { successfulDoubleClick = false; singleClick = false; } else if (Input.GetKeyDown(KeyCode.P) && camState == CamState.camTower) { camState = CamState.camMain; StartCoroutine("TowerToMainRoutine"); } else if (Input.GetKeyDown(KeyCode.P) && camState == CamState.camFish) { camState = CamState.camMain; StartCoroutine("FishToMainRoutine"); } /* * else if (Input.GetKeyDown(KeyCode.O) && camState == CamState.camMain) * { * camState = CamState.camFish; * StartCoroutine("MainToFishRoutine"); * } * * else if (Input.GetKeyDown(KeyCode.O) && camState == CamState.camFish) * { * camState = CamState.camMain; * StartCoroutine("FishToMainRoutine"); * } */ if (camState == CamState.camMain) { CamMainUpdate(); } else if (camState == CamState.camTower) { CamTowerUpdate(); } else if (camState == CamState.camFish) { CamFishUpdate(); } }
void Update() { if (Input.touchCount != 0) { if (Input.GetTouch(0).phase == TouchPhase.Began) { allowMove = !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId); } if (Input.GetTouch(0).phase == TouchPhase.Ended) { if (movedist < movedistthresh && allowMove) { CreationController.cc.Deselect(); } movedist = 0; allowMove = true; } if (Input.GetTouch(0).phase == TouchPhase.Moved) { movedist += (Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition).magnitude; } } if (!allowMove) { return; } switch (state) { case CamState.moving: if (Input.touchCount == 2) { state = CamState.zooming; break; } if (Input.touchCount == 0) { state = CamState.none; break; } if (movedist > movedistthresh) { Vector3 direction = touchStart - Camera.main.ScreenToWorldPoint(new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, Camera.main.transform.position.y - CreationController.cc.backgroundPlane.position.y)); Camera.main.transform.position += direction; } break; case CamState.zooming: if (Input.touchCount == 1) { break; } if (Input.touchCount == 0) { state = CamState.none; break; } Touch touchZero = Input.GetTouch(0); Touch touchOne = Input.GetTouch(1); Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition; float prevMagnitude = (touchZeroPrevPos - touchOnePrevPos).magnitude; float currentMagnitude = (touchZero.position - touchOne.position).magnitude; float difference = currentMagnitude - prevMagnitude; zoom(difference * 0.02f); break; case CamState.none: if (Input.touchCount != 0) { if (Input.GetTouch(0).phase == TouchPhase.Ended) { break; } touchStart = Camera.main.ScreenToWorldPoint(new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, Camera.main.transform.position.y - CreationController.cc.backgroundPlane.position.y)); state = CamState.moving; } break; } }
void Awake() { state = CamState.FollowingPlayer; }
public void HeadLeanRight() { //Debug.Log("lean right"); //db("lean right"); cameraState = CamState.None; }
public void HeadFullShake() { //Debug.Log("full shake"); //db("full shake"); cameraState = CamState.HeadShook; }
public void HeadFullSideNod() { //Debug.Log("full side nod"); //db("full side nod"); cameraState = CamState.None; }
public void HeadNodRight() { //Debug.Log("nod right"); //db("nod right"); cameraState = CamState.None; }
public void HeadNodLeft() { //Debug.Log("nod left"); //db("nod left"); cameraState = CamState.None; }
public void lerpTo(CamState targCam, float smoothingPos, float smoothingRot) { position = Vector3.Lerp(position, targCam.position, smoothingPos); rotation = Quaternion.Lerp(rotation, targCam.rotation, smoothingRot); }
/// <summary> /// Default CamState delegate, used before any switches are called. /// </summary> /// <param name="state">CamState from previous frame.</param> protected virtual CamState GetStateDefault(CamState state) { return(state); }
/// <summary> /// Apply CamState for current frame. /// </summary> /// <remarks> /// Useful to override in case you want last-minute edits, such as clamping. /// </remarks> /// <param name="state">Target state, post-tween.</param> protected virtual void SetState(CamState state) { transform.position = state.pos; transform.LookAt(state.target, state.up); SetFOV(state.fov); }
public void SetCamState(CamState state) { DisableAllvCams(); currentState = state; GetvCamByCurrentState().SetActive(true); }
public void HeadTiltUp() { //Debug.Log("tilt up"); //db("tilt up"); cameraState = CamState.None; }
public void HeadTiltDown() { //Debug.Log("tilt down at "); //db("tilt down at "); cameraState = CamState.None; }
public void HeadLeanLeft() { //ebug.Log("lean left"); //db("lean left"); cameraState = CamState.None; }
public void HeadNodUp() { //Debug.Log("nod up "); //db("nod up "); cameraState = CamState.None; }
public void DisableFocus() { state = CamState.FollowingPlayer; }
public void HeadNodDown() { //Debug.Log("nod down"); //db("nod down"); cameraState = CamState.None; }
public void EnableFocus(Transform focus) { focusedObject = focus; state = CamState.Focused; }
public void HeadFullNod() { //Debug.Log("full nod"); //db("full nod"); cameraState = CamState.Nodded; }
// Use this for initialization private void Start() { state = CamState.Reset; if (follow == null) follow = GameObject.FindGameObjectWithTag("Follow").transform; followScript = follow.GetComponent<FollowPlayer>(); if (player == null) player = GameObject.FindGameObjectWithTag("Player").transform; initialAngle = follow.forward; }
public void HeadTurnLeft() { //Debug.Log("turn left"); //db("turn left"); cameraState = CamState.None; }
public void SetState(CamState camState) { transform.position = camState.position; MoveTo(camState.position); transform.rotation = Quaternion.Euler(0, camState.YRotation, 0); }
public void HeadTurnRight() { //Debug.Log("turn right"); //db("turn right"); cameraState = CamState.None; }
void SetCameraPanTarget(GameObject target) { panToTargetDistance = Vector3.Distance(transform.position, TargetCameraOffset(target)); panToTargetSpeed = panToTargetDistance * panToTargetSpeedMult; state = CamState.PanToTarget; }
public void HeadShakeLeft() { //Debug.Log("shake left"); //db("shake left"); cameraState = CamState.None; }
void LateUpdate() { switch (camState) { case CamState.Behind: lookDir = m_look.position - transform.position; lookDir.y = 0; lookDir.Normalize(); CameraRotate(); break; case CamState.Target: lookDir = m_target.position - m_look.position; lookDir.y = 0; lookDir.Normalize(); CameraRotateTarget(); break; case CamState.Reset: curAway = distanceAway; // curUp = distanceUp; lookDir = m_look.transform.forward; CameraRotate(); break; } if (camState == CamState.Reset) { if ((transform.position - desiredRigPos).magnitude < 0.05f || Mathf.Abs(Input.GetAxisRaw("Horizontal")) > 0.1f || Mathf.Abs(Input.GetAxisRaw("Vertical")) > 0.1f) { camState = CamState.Behind; } } //Vector3 lookPos = (camState == CamState.Target) ? targetPos : m_look.position; Vector3 lookPos = m_look.position; Vector3 localLookPos = m_camera.InverseTransformPoint(lookPos); Vector3 localSmoothedLookPos = m_camera.InverseTransformPoint(smoothedLookPos); localSmoothedLookPos.y = localLookPos.y; localSmoothedLookPos.z = localLookPos.z; smoothedLookPos = m_camera.TransformPoint(localSmoothedLookPos); smoothedLookPos = Vector3.SmoothDamp(smoothedLookPos, lookPos, ref sVel2, smooth * 1.3f); if (camState == CamState.Reset) { transform.position = Vector3.SmoothDamp(transform.position, desiredRigPos, ref sVel1, smooth * 0.12f); } else { transform.position = desiredRigPos; } if (camCol.Collide(smoothedLookPos, desiredRigPos)) { m_camera.position = Vector3.SmoothDamp(m_camera.position, camCol.targetPos, ref sVel3, smooth * 0.01f); } else { m_camera.position = transform.position; } //transform.LookAt (smoothedLookPos); if (camState == CamState.Target) { m_camera.LookAt(m_target.position); } else { m_camera.LookAt(smoothedLookPos); } }
public void HeadShakeRight() { //Debug.Log("shake right"); //db("shake right"); cameraState = CamState.None; }
IEnumerator Wait() { yield return(new WaitForSeconds(2f)); camState = CamState.Panning; }
void SetCamFirstPerson() => CurrentCamState = CamState.FirstPerson;