//This function handles player input void HandlePlayerInput() { float deadZone = 0.01f; //If Right Mouse button is clicked if (Input.GetMouseButton(1)) { // The RMB is down get mouse axis input mouseX += Input.GetAxis("Mouse X") * mouseSensitivityX; mouseY -= Input.GetAxis("Mouse Y") * mouseSensitivityY; } // This is where we will limit mouseY //Mouse Y will be clamped by the Mouse Helper Class mouseY = CharacterCameraHelper.ClampAngle(mouseY, minLimitY, maxLimitY); //If Scrolling and outside deadzone if (Input.GetAxis("Mouse ScrollWheel") < -deadZone || Input.GetAxis("Mouse ScrollWheel") > deadZone) { //Clamp the desired distance desiredDistance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") * mouseWheelSensitivity, distanceMin, distanceMax); preOccludedDistance = desiredDistance; distSmooth = distanceSmooth; } }
float CheckCameraPoints(Vector3 from, Vector3 to) { var nearestDistance = -1f; RaycastHit hitInfo; CharacterCameraHelper.ClipPlanePoints clipPlanePoints = CharacterCameraHelper.ClipPlaneAtNear(to); // Draw Lines in the editor to make it easier to visualize Debug.DrawLine(from, to + transform.forward * -GetComponent <Camera>().nearClipPlane, Color.red); Debug.DrawLine(from, clipPlanePoints.UpperLeft); Debug.DrawLine(from, clipPlanePoints.LowerLeft); Debug.DrawLine(from, clipPlanePoints.UpperRight); Debug.DrawLine(from, clipPlanePoints.LowerRight); Debug.DrawLine(clipPlanePoints.UpperLeft, clipPlanePoints.UpperRight); Debug.DrawLine(clipPlanePoints.UpperRight, clipPlanePoints.LowerRight); Debug.DrawLine(clipPlanePoints.LowerRight, clipPlanePoints.LowerLeft); Debug.DrawLine(clipPlanePoints.LowerLeft, clipPlanePoints.UpperLeft); if (Physics.Linecast(from, clipPlanePoints.UpperLeft, out hitInfo) && hitInfo.collider.tag != "Player") { nearestDistance = hitInfo.distance; } if (Physics.Linecast(from, clipPlanePoints.LowerLeft, out hitInfo) && hitInfo.collider.tag != "Player") { if (hitInfo.distance < nearestDistance || nearestDistance == -1) { nearestDistance = hitInfo.distance; } } if (Physics.Linecast(from, clipPlanePoints.UpperRight, out hitInfo) && hitInfo.collider.tag != "Player") { if (hitInfo.distance < nearestDistance || nearestDistance == -1) { nearestDistance = hitInfo.distance; } } if (Physics.Linecast(from, clipPlanePoints.LowerRight, out hitInfo) && hitInfo.collider.tag != "Player") { if (hitInfo.distance < nearestDistance || nearestDistance == -1) { nearestDistance = hitInfo.distance; } } if (Physics.Linecast(from, to + transform.forward * -GetComponent <Camera>().nearClipPlane, out hitInfo) && hitInfo.collider.tag != "Player") { if (hitInfo.distance < nearestDistance || nearestDistance == -1) { nearestDistance = hitInfo.distance; } } return(nearestDistance); }