var target : Transform; // Target objectvar Distance = 10.0; // Default distance value. Default value is likely to change from scene to scenevar MaxDistance = 15.0; // Maximum distance the camera can get from the target object (Old behaviour variable but may be handy later for combat)var MinDistance = 5.0; // Minimum distance the camera can be from the target object (Old behaviour variable but may be handy later for combat)var xSpeed = 125.0; // Base factor to increase rotational speedvar ySpeed = 50.0; // Base factor to increase rotational speedvar position; // Position variable for move cameraprivate var x = 0.0; // Store the x axis location during camera movementprivate var y = 0.0; // Store the y axis location during camera movementfunction Start () {// Nothing here, but no point removing it just yet}function LateUpdate () { // Do the following right at the end var rotation = Quaternion.Euler(y, x, 0); transform.rotation = rotation; //Rotate the camera to those angles position = rotation * Vector3(0, 3.0, -Distance) + target.position; transform.position = position; if(target) { // Only enable mouse camera movement if there is a target object set if(Input.GetMouseButton(1)) { // When right mouse button is clicked //Change the angles by mouse input x += Input.GetAxis("Mouse X") * xSpeed * 0.02; y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02; } if(Input.GetAxis("Mouse ScrollWheel") < 0) { // If the scroll wheel is being scrolled down if(Distance <= 200) { Distance += 5; } } if(Input.GetAxis("Mouse ScrollWheel") > 0) { // If the scroll whell is being scrolled up if(Distance >= 20) { Distance -= 5; } } } // End of target IF chunk} // End of LateUpdatefunction ChangeTarget (NewTarget : Transform) { // Function used by System Select script to change camera focus print ("Setting new target as " + NewTarget); target = NewTarget;}