Screenshake script
This commit is contained in:
parent
eaef42e6a8
commit
60734a9260
@ -78,6 +78,7 @@ GameObject:
|
|||||||
- component: {fileID: 8365024801038495440}
|
- component: {fileID: 8365024801038495440}
|
||||||
- component: {fileID: 8365024801038495454}
|
- component: {fileID: 8365024801038495454}
|
||||||
- component: {fileID: 8365024801038495455}
|
- component: {fileID: 8365024801038495455}
|
||||||
|
- component: {fileID: 1531181312}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: cm
|
m_Name: cm
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -154,6 +155,23 @@ MonoBehaviour:
|
|||||||
m_MaximumFOV: 60
|
m_MaximumFOV: 60
|
||||||
m_MinimumOrthoSize: 1
|
m_MinimumOrthoSize: 1
|
||||||
m_MaximumOrthoSize: 5000
|
m_MaximumOrthoSize: 5000
|
||||||
|
--- !u!114 &1531181312
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8365024801038495441}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 68bb026fafb42b14791938953eaace77, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_NoiseProfile: {fileID: 11400000, guid: 46965f9cbaf525742a6da4c2172a99cd, type: 2}
|
||||||
|
m_PivotOffset: {x: 0, y: 0, z: 0}
|
||||||
|
m_AmplitudeGain: 0
|
||||||
|
m_FrequencyGain: 0
|
||||||
|
mNoiseOffsets: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &8365024801073869719
|
--- !u!1 &8365024801073869719
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -164,6 +182,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 8365024801073869717}
|
- component: {fileID: 8365024801073869717}
|
||||||
- component: {fileID: 8365024801073869718}
|
- component: {fileID: 8365024801073869718}
|
||||||
|
- component: {fileID: 2035066971}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: VCam Vampire
|
m_Name: VCam Vampire
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -221,6 +240,18 @@ MonoBehaviour:
|
|||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_LegacyBlendHint: 0
|
m_LegacyBlendHint: 0
|
||||||
m_ComponentOwner: {fileID: 8365024801038495440}
|
m_ComponentOwner: {fileID: 8365024801038495440}
|
||||||
|
--- !u!114 &2035066971
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8365024801073869719}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 69316e5653a69e04a97ae92bd78b1430, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &8365024801698166082
|
--- !u!1 &8365024801698166082
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
30
Assets/Scripts/ScreenShaker.cs
Normal file
30
Assets/Scripts/ScreenShaker.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using Cinemachine;
|
||||||
|
|
||||||
|
public class ScreenShaker : MonoBehaviour {
|
||||||
|
|
||||||
|
CinemachineVirtualCamera cam;
|
||||||
|
CinemachineBasicMultiChannelPerlin noise;
|
||||||
|
|
||||||
|
void Awake() {
|
||||||
|
cam = GetComponent<CinemachineVirtualCamera>();
|
||||||
|
noise = cam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Shake(float magnitude = 1f, float duration = 0.2f) {
|
||||||
|
StartCoroutine(ShakeCoroutine(magnitude, duration));
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator ShakeCoroutine(float magnitude, float duration) {
|
||||||
|
noise.m_AmplitudeGain = magnitude;
|
||||||
|
noise.m_FrequencyGain = 10f;
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(duration);
|
||||||
|
|
||||||
|
noise.m_AmplitudeGain = 0f;
|
||||||
|
noise.m_FrequencyGain = 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Scripts/ScreenShaker.cs.meta
Normal file
11
Assets/Scripts/ScreenShaker.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 69316e5653a69e04a97ae92bd78b1430
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user