Camera follow Player smoothly

This commit is contained in:
2023-10-10 12:10:42 +02:00
parent 3f6fb6976a
commit 2abdb96912
10 changed files with 118 additions and 197 deletions
+16
View File
@@ -0,0 +1,16 @@
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
private Vector3 _offset = new Vector3(0f, 0f, -10f);
private float _smoothTime = 10f;
private Vector3 _velocity = Vector3.zero;
[SerializeField] private Transform _target;
private void FixedUpdate()
{
Vector3 targetPosition = _target.position + _offset;
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _velocity, _smoothTime * Time.deltaTime);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c21915c57411c34c826d82960a3a4b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: