init
This commit is contained in:
commit
3b4c6e0ec6
506 changed files with 434142 additions and 0 deletions
33
Assets/Scripts/ScreenShakeCall.cs
Normal file
33
Assets/Scripts/ScreenShakeCall.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using Cinemachine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ScreenShakeCall : MonoBehaviour{
|
||||
|
||||
CinemachineVirtualCamera vCam;
|
||||
float shakeTimer;
|
||||
float shakeTimerTotal;
|
||||
float startingIntensity;
|
||||
|
||||
public static ScreenShakeCall instance { get; private set; }
|
||||
|
||||
void Awake(){
|
||||
instance = this;
|
||||
vCam = GetComponent<CinemachineVirtualCamera>();
|
||||
}
|
||||
|
||||
public void ShakeCamera(float intensity, float time){
|
||||
CinemachineBasicMultiChannelPerlin multiChannelPerlin = vCam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
|
||||
startingIntensity = intensity;
|
||||
shakeTimer = shakeTimerTotal = time;
|
||||
}
|
||||
|
||||
void Update(){
|
||||
if(shakeTimer > 0){
|
||||
shakeTimer -= Time.deltaTime;
|
||||
CinemachineBasicMultiChannelPerlin multiChannelPerlin = vCam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
|
||||
multiChannelPerlin.m_AmplitudeGain = Mathf.Lerp(startingIntensity, 0f, 1 - (shakeTimer / shakeTimerTotal));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue