23 lines
542 B
C#
23 lines
542 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class CameraFollow : MonoBehaviour {
|
|||
|
public Transform target;
|
|||
|
public Vector3 offset;
|
|||
|
public float smoothSpeed = 1.0f;
|
|||
|
|
|||
|
|
|||
|
// Use this for initialization
|
|||
|
|
|||
|
void Update ()
|
|||
|
{
|
|||
|
Vector3 desiredPosition = target.position + offset;
|
|||
|
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
|
|||
|
transform.position = smoothedPosition;
|
|||
|
|
|||
|
transform.LookAt(target);
|
|||
|
|
|||
|
}
|
|||
|
}
|