Files
SimUL/Assets/Scripts/CameraPlayerFollow.cs
T
vova b58221dc98 remove unnecessary models in animation folder
player waypoint indicator
walk and idle animations
stop when menu opens
2022-11-16 23:17:02 +02:00

27 lines
655 B
C#

using UnityEngine;
public class CameraPlayerFollow : MonoBehaviour
{
[SerializeField]
private Transform _playerTransform;
private Vector3 _cameraOffset;
[SerializeField]
[Range(0.01f, 1.0f)]
private float _smoothFactor = 0.5f;
// Start is called before the first frame update
void Start()
{
_cameraOffset = transform.position - _playerTransform.position;
transform.LookAt(_playerTransform);
}
void LateUpdate()
{
Vector3 newPosition = _playerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPosition, _smoothFactor);
}
}