A z tohoto?
var cameraTransform : Transform;
private var _target : Transform;
// The distance in the x-z plane to the target
var distance = 7.0;
// the height we want the camera to be above the target
var height = 3.0;
var angularSmoothLag = 0.3;
var angularMaxSpeed = 15.0;
var heightSmoothLag = 0.3;
var snapSmoothLag = 0.2;
var snapMaxSpeed = 720.0;
var clampHeadPositionScreenSpace = 0.75;
var lockCameraTimeout = 0.2;
private var headOffset = Vector3.zero;
private var centerOffset = Vector3.zero;
private var heightVelocity = 0.0;
private var angleVelocity = 0.0;
private var snap = false;
private var controller : ThirdPersonController;
private var targetHeight = 100000.0;
function Awake ()
{
function DebugDrawStuff ()
{
Debug.DrawLine(_target.position, _target.position + headOffset);
}
function AngleDistance (a : float, b : float)
{
a = Mathf.Repeat(a, 360);
b = Mathf.Repeat(b, 360);
return Mathf.Abs(b - a);
}
function Apply (dummyTarget : Transform, dummyCenter : Vector3)
{
// Early out if we don't have a target
if (!controller)
return;
var targetCenter = _target.position + centerOffset;
var targetHead = _target.position + headOffset;
// DebugDrawStuff();
{
if (controller.GetLockCameraTimer () < lockCameraTimeout)
{
targetAngle = currentAngle;
}
// Lock the camera when moving backwards!
// * It is really confusing to do 180 degree spins when turning around.
if (AngleDistance (currentAngle, targetAngle) > 160 && controller.IsMovingBackwards ())
targetAngle += 180;
// Set the height of the camera
cameraTransform.position.y = currentHeight;
// Always look at the target
SetUpRotation(targetCenter, targetHead);
}
function LateUpdate () {
Apply (transform, Vector3.zero);
}
function Cut (dummyTarget : Transform, dummyCenter : Vector3)
{
var oldHeightSmooth = heightSmoothLag;
var oldSnapMaxSpeed = snapMaxSpeed;
var oldSnapSmooth = snapSmoothLag;
snapMaxSpeed = 10000;
snapSmoothLag = 0.001;
heightSmoothLag = 0.001;
snap = true;
Apply (transform, Vector3.zero);
heightSmoothLag = oldHeightSmooth;
snapMaxSpeed = oldSnapMaxSpeed;
snapSmoothLag = oldSnapSmooth;
}
else
{
extraLookAngle = extraLookAngle - centerToTopAngle;
cameraTransform.rotation *= Quaternion.Euler(-extraLookAngle, 0, 0);
}
}
function GetCenterOffset ()
{
return centerOffset;
}