holopy3/Assets/Monarch/Scripts/CameraFollow.cs
2020-12-10 15:25:12 +01:00

22 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);
}
}