28 lines
819 B
C#
28 lines
819 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class CameraFollower : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private Transform _followTarget;
|
||
|
[SerializeField] private Camera _camera;
|
||
|
[SerializeField] private float _rotationSmooth;
|
||
|
[SerializeField] private float _positionSmooth;
|
||
|
|
||
|
private Vector3 _positionDiff;
|
||
|
private Quaternion _rotationDiff;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
_positionDiff = _camera.transform.position - _followTarget.position;
|
||
|
//_rotationDiff = _camera.transform.rotation - _followTarget.rotation;
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void LateUpdate()
|
||
|
{
|
||
|
_camera.transform.position = _followTarget.position + _positionDiff;
|
||
|
_camera.transform.LookAt(_followTarget);// = _followTarget.rotation + _rotationDiff;
|
||
|
}
|
||
|
}
|