// Update is called once per frame void LateUpdate() { // When player clicks on right mouse button if (Input.GetButton("Fire2")) { // Changing the pitch when player is holding right click float mouseAxisY = Input.GetAxis("Mouse Y"); float mouseAxisX = Input.GetAxis("Mouse X"); theTargetYaw += mouseAxisX * mouseXSensitivity; theTargetPitch += mouseAxisY * mouseYSensitivity; } // Changes the pich rotation theTargetPitch = Mathf.Clamp(theTargetPitch, -85, 85); // Clamping the rotation so the camera doesn't get stuck or freak out at 90 degrees // Easing thePitch = OrbitalMathAnim.SlidingEffect(thePitch, theTargetPitch, .05f); theYaw = OrbitalMathAnim.SlidingEffect(theYaw, theTargetYaw, .05f); // Rotating using Quaternion transform.rotation = Quaternion.Euler(thePitch, theYaw, 0); float scrollWheel = Input.GetAxisRaw("Mouse ScrollWheel"); // Gets value when player uses the scroll wheel theTargetDollyDis += scrollWheel * mouseScrollMultiplier; theTargetDollyDis = Mathf.Clamp(theTargetDollyDis, TargetObject.distanceZoomMin, TargetObject.distanceZoomMax); // clamps the zoom theDollyDistance = OrbitalMathAnim.SlidingEffect(theDollyDistance, theTargetDollyDis, .05f); // Sliding effect when the player zooms in and out assignedCams.transform.localPosition = new Vector3(0, 0, -theDollyDistance); // Zooms in and out by using Vector3 }
void FixedUpdate() { if (tweenTime < tweenDur) { tweenTime += Time.unscaledDeltaTime * quickerTransition; quickerTransition++; } Vector3 trailingPOS = OrbitalMathAnim.SlidingEffect(transform.position, targetToLock.transform.position, .001f, Time.unscaledDeltaTime); float result = tweenTime / tweenDur; transform.position = OrbitalMathAnim.LerpFunc(trailingPOS, targetToLock.transform.position, Mathf.Clamp(result, 0, 1)); print(result); }