Orbit camera to follow player.

The title isn’t too specific, but what I want is: camera is orbiting free when stand-still, but when moving the camera would slowly float behind the player’s back, to show things in front of you. Good example would be something like Zelda: Wind Waker or Super Mario Sunshine. Currently I’m using the MouseOrbit.js script, with the awesome modification by robertpu down there. Thanks in advance.

PS. I’m a beginner.

Here is a quick edit to the MouseOrbit script. It will center on the back when the ‘A’ key is pressed. Essentially the changes were lines 34 - 40.

#pragma strict

var target : Transform;
var distance = 10.0;

var xSpeed = 250.0;
var ySpeed = 120.0;

var yMinLimit = -20;
var yMaxLimit = 80;

private var x = 0.0;
private var y = 0.0;

@script AddComponentMenu("Camera-Control/Mouse Orbit")

function Start () {
    var angles = transform.eulerAngles;
    x = angles.y;
    y = angles.x;

	// Make the rigid body not change rotation
   	if (rigidbody)
		rigidbody.freezeRotation = true;
}

function LateUpdate () {
    if (target) {
        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
 		
 		y = ClampAngle(y, yMinLimit, yMaxLimit);
 
 		if (Input.GetKeyDown(KeyCode.A)) {
 			transform.position = target.position - target.forward * distance;
 			transform.LookAt(target);
 			var angles = transform.eulerAngles;
    		x = angles.y;
    		y = angles.x; 
 		} 
 		else {
 			var rotation = Quaternion.Euler(y, x, 0);
        	transform.rotation = Quaternion.Euler(y, x, 0);
        	transform.position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
       	}
    }
}

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);
}