纳金网
标题:
镜头旋转问题
[打印本页]
作者:
她。
时间:
2012-8-7 10:38
标题:
镜头旋转问题
按右键镜头旋转完之后会停在一个地方
怎么解决第二次按右键画面在上一个角度的问题?
// The target we are following
var target : Transform;
// The distance in the x-z plane to the target
var distance = 10.0;
// the height we want the camera to be above the target
var height = 5.0;
// How much we
var heightDamping = 2.0;
var rotationDamping = 3.0;
var sensitivityX : float = 15;
var sensitivityY : float = 15;
var minimumX : float= -360;
var maximumX : float = 360;
var minimumY : float = -60;
var maximumY : float = 60;
var rotationX : float = 0;
var rotationY : float = 0;
var originalRotation : Quaternion ;
function Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = ***e;
originalRotation = transform.localRotation;
}
function ClampAngle (angle : float, min : float , max : float)
{
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}
// Place the script in the Camera-Control group in the component menu
@script AddComponentMenu("Camera-Control/Smooth Follow")
function FixedUpdate () {
//transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform);
if (Input.GetButton("Fire2")&&(Mathf.Abs(Input.GetAxis("Horizontal")) == 0 ) ){
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationX = ClampAngle (rotationX, minimumX, maximumX);
var xQuaternion : Quaternion ;
xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
}
function LateUpdate () {
// Early out if we don't have a target
if (!target)
return;
// Calculate the current rotation angles
wantedRotationAngle = target.eulerAngles.y;
wantedHeight = target.position.y + height;
currentRotationAngle = transform.eulerAngles.y;
currentHeight = transform.position.y;
// Damp the rotation around the y-axis
currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);
// Damp the height
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
// Convert the angle into a rotation
currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = target.position;
transform.position -= currentRotation * Vector3.forward * distance;
// Set the height of the camera
transform.position.y = currentHeight;
// Always look at the target
transform.LookAt (target);
}
作者:
她。
时间:
2012-8-7 10:48
哎呀~各位别光看不回帖啊~ 支持下啊!
作者:
其实我是神
时间:
2012-8-7 16:41
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5