rabidus-test/Assets/00_CI/CameraFollower.cs

28 lines
819 B
C#
Raw Normal View History

2023-10-30 12:42:09 +03:00
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;
}
}