publicfloat distanceAway; // distance from the back of the craftpublicfloat distanceUp; // distance above the craftpublicfloat smooth; // how smooth the camera movement is
GameObject hovercraft; // to store the hovercraft
Vector3 targetPosition; // the position the camera is trying to be in
Transform follow;
void Start ()
{
follow = GameObject.FindWithTag ("Player").transform;
}
void LateUpdate ()
{
// setting the target position to be the correct offset from the hovercraft
targetPosition = follow.position + Vector3.up * distanceUp + follow.forward * distanceAway;
// making a smooth transition between it's current position and the position it wants to be in
transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth);
// make sure the camera is looking the right way!
transform.LookAt (follow);
}
Vector3 offset;
Transform fly;
// Use this for initialization
void Start () {
fly = GameObject .FindGameObjectWithTag ("Player").transform;
offset = fly .position - transform .position;
}
// Update is called once per frame
void Update () {
transform .position = new Vector3 (fly .position.x -offset .x ,transform .position.y ,fly .position.z -offset .z) ;
}