var distanceMin = 4;
var distanceMax = 45;
function LateUpdate () {
if (target) {
distance = Mathf.Clamp(distance - Input.GetAxis(“Camera Zoom”)*5, distanceMin, distanceMax);
if (Input.mousePosition.x > Screen.width - 2 || Input.mousePosition.x < 2 || Input.mousePosition.y > Screen.height - 2 || Input.mousePosition.y < 2) DoIT = 1;
else DoIT = 0;
if (FirstLogin == 0) { FirstLogin = 1; DoIT = 1; }
if (DoIT == 1) {
if (Input.mousePosition.x > Screen.width - 2) x += 60 * xSpeed * 0.02 * Time.deltaTime;
if (Input.mousePosition.x < 2) x -= 60 * xSpeed * 0.02 * Time.deltaTime;
if (Input.mousePosition.y < 2) y += 30 * ySpeed * 0.02 * Time.deltaTime;
if (Input.mousePosition.y > Screen.height - 2) y -= 30 * ySpeed * 0.02 * Time.deltaTime;
y = ClampAngle(y, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
var hit : RaycastHit;
if (Physics.Linecast (target.position, transform.position, hit)) {
distance -= hit.distance;
}
transform.rotation = rotation;
transform.position = position;
lastPos = transform.position - target.position;
}
else transform.position = target.transform.position + lastPos;
}
}
static function ClampAngle (angle : float, min : float, max : float) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}
function StartTheCam() {
distance = Mathf.Clamp(distance - Input.GetAxis(“Camera Zoom”)*5, distanceMin, distanceMax);
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
y = ClampAngle(y, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(y, 0, 0);
var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
transform.rotation = rotation;
transform.position = position;
lastPos = transform.position - target.position;
transform.position = target.transform.position + lastPos;
}
i dont really know how to do it but this works
but the zoom doesnt show it has worked till you move the camera again. it mightjust be in the wrong spot lol