Graphics Reference
In-Depth Information
float currentRotationAngle;
float currentHeight;
Quaternion currentRotation;
Vector3 wantedPosition;
private float yVelocity = 0.0F;
private float zVelocity = 0.0F;
public override void SetTarget( Transform aTarget )
{
target= aTarget;
}
void LateUpdate ()
{
if ( target == null )
return;
if ( myTransform==null )
{
myTransform=Transform;
}
wantedHeight = target.position.y + height;
currentHeight = myTransform.position.y;
wantedRotationAngle = target.eulerAngles.y;
currentRotationAngle = myTransform.eulerAngles.y;
currentRotationAngle = Mathf.SmoothDampAngle(currentRotation
Angle, wantedRotationAngle, ref yVelocity, rotationSnapTime);
currentHeight = Mathf.Lerp(currentHeight, wantedHeight,
heightDamping * Time.deltaTime);
wantedPosition = target.position;
wantedPosition.y = currentHeight;
usedDistance = Mathf.SmoothDampAngle(usedDistance, distance,
ref zVelocity, distanceSnapTime);
wantedPosition += Quaternion.Euler(0, currentRotationAngle,
0) * new Vector3(0, 0, -usedDistance);
Search WWH ::




Custom Search