Você está na página 1de 1

// DGH1 // Oisin Bourke #pragma strict var target : Transform; // Following variables define distance to character and height.

private var distance : float = 20.0; private var height : float = 10.0; // This rotationDamping variable gives a delay to camera movement, this can feel like a more natural, smooth movement in some games, less jerky private var rotationDamping : float = 3.0; // LateUpdate() functions are called last, in this case giving camera positionin g. function LateUpdate () { var wantedRotationAngle = target.eulerAngles.y; var wantedHeight = target.position.y + height; var currentRotationAngle = transform.eulerAngles.y; var currentHeight = transform.position.y; // If the "CameraZoomIn" button is pressed the camera distance changes if(Input.GetButton("CameraZoomIn")) { distance-=1; } // If the "CameraZoomOut" button is pressed the camera distance changes if(Input.GetButton("CameraZoomOut")) { distance += 1; } // The following statements and variables use Quaternions to keep the camera the same distance from the character currentRotationAngle = Mathf.LerpAngle(currentRotationAngle,wantedRotati onAngle,rotationDamping*Time.deltaTime); var currentRotation = Quaternion.Euler (0, currentRotationAngle, 0); transform.position = target.position; transform.position -= currentRotation*Vector3.forward*distance; transform.position.y = wantedHeight; transform.LookAt(target); }

Você também pode gostar