Improooove !
This commit is contained in:
+1608
-2262
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CameraFollow : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
private Transform _followTarget;
|
||||||
|
[SerializeField]
|
||||||
|
private float _smoothTime = 0.15f;
|
||||||
|
[SerializeField]
|
||||||
|
private bool _stopAtXedges=false;
|
||||||
|
[SerializeField]
|
||||||
|
private float _maxXValue = 0f;
|
||||||
|
[SerializeField]
|
||||||
|
private float _minXValue = 0f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Vector3 _velocity= Vector3.zero;
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
var targetPosition=_followTarget.position;
|
||||||
|
targetPosition.z = transform.position.z;
|
||||||
|
targetPosition.y = transform.position.y;
|
||||||
|
|
||||||
|
if (_stopAtXedges)
|
||||||
|
{
|
||||||
|
targetPosition.x = Mathf.Clamp(targetPosition.x, _minXValue, _maxXValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _velocity,_smoothTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1734c77596ffe1742882362d0b2fe3e2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user