Camera Basic functions

Hi,

Here is my camera script in this script rotation and zoom working but pan function not working properly. Please help me to solve this issue.

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;

private var xx = 0;
private var yy = 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(Input.GetMouseButton(0))
		{		
		    if (target) 
		    {
		        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
		        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;	  		

		    }
		 }		 

		 if(Input.GetMouseButton(1))
		 {		       

		 	 transform.Translate(Vector3.right * -Input.GetAxis("Mouse X") * 20, Space.Self );

                         transform.Translate(transform.up * -Input.GetAxis("Mouse Y") * 20 , Space.Self);				

		 }

		 

		  y = ClampAngle(y, yMinLimit, yMaxLimit);

		 

//		  var traspos = Vector3(xx, -yy, 0);

		 

		distance -= Input.GetAxis("Mouse ScrollWheel") * 3;

		distance = Mathf.Clamp(distance, 0.7, 10);

		distance = Mathf.Lerp(distance, distance, 2.0f);

		

        var rotation = Quaternion.Euler(y, x, 0);        

        transform.rotation = rotation;
        var position = rotation * Vector3(0, 0, -distance) + target.position + transform.position * 0.20;    
        transform.position = 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);

}

‘not working right’ - we can’t help you

‘is supposed to do this, but instead it’s doing that. how do i make it do this?’ - very nice. muy bueno.

you probably just need to apply Time.deltaTime multiplication to your pan speeds. It also looks like your second .Translate is silly. It would be easier to read/maintain if you just use transform.position += transform.up * panSpeed * Time.deltaTime or something similar.