asset integration 50%
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class CameraEffects : MonoBehaviour
|
||||
{
|
||||
public static CameraEffects instance;
|
||||
Camera cam;
|
||||
|
||||
[SerializeField]private float stretchFactor = 0;
|
||||
[SerializeField]private bool isBeingStretched = false;
|
||||
[SerializeField]private float minFov = 5;
|
||||
[SerializeField]private float maxFov = 10;
|
||||
[SerializeField]private float fovSpeed = 10;
|
||||
[SerializeField] private float bounceDuration = 0.35f;
|
||||
[SerializeField] private float bounceElasticity = 0.7f;
|
||||
[SerializeField] private float bounceOvershoot = 0.2f;
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
cam = Camera.main;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(isBeingStretched){
|
||||
float targetFov = minFov + stretchFactor * (maxFov - minFov);
|
||||
cam.orthographicSize = Mathf.Lerp(cam.orthographicSize, targetFov, Time.deltaTime * fovSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetStretchFactor(float stretchFactor){
|
||||
this.stretchFactor = stretchFactor;
|
||||
isBeingStretched = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ReleaseStretchFactor(){
|
||||
stretchFactor = 0;
|
||||
isBeingStretched = false;
|
||||
cam.DOOrthoSize(minFov, bounceDuration)
|
||||
.SetEase(Ease.OutElastic, bounceElasticity, bounceOvershoot)
|
||||
.OnComplete(() => {
|
||||
stretchFactor = 0;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user