mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-24 02:20:58 +00:00
Camera shakeable
This commit is contained in:
parent
823631921a
commit
412af97ba8
@ -40,7 +40,7 @@ AudioSource:
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 3d4d970a0bbdd934e95ffcf72fc5225c, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Volume: 0.01
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
|
||||
@ -86,7 +86,7 @@ AudioSource:
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 3d4d970a0bbdd934e95ffcf72fc5225c, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Volume: 0.01
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
@ -160,7 +160,7 @@ AudioSource:
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 3d4d970a0bbdd934e95ffcf72fc5225c, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Volume: 0.01
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
|
||||
36
Assets/Scripts/CameraShake.cs
Normal file
36
Assets/Scripts/CameraShake.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class CameraShake : MonoBehaviour
|
||||
{
|
||||
|
||||
public float shakeTimeAmount = 0.0f;
|
||||
public float shakeAmount = 0.7f;
|
||||
public float decreaseFactor = 1.0f;
|
||||
|
||||
private Camera camera;
|
||||
|
||||
// Use this for initialization
|
||||
public void Start ()
|
||||
{
|
||||
camera = gameObject.GetComponent<Camera>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public void FixedUpdate () {
|
||||
if (shakeTimeAmount > 0)
|
||||
{
|
||||
var tempShakePosition = camera.transform.localPosition = Random.insideUnitSphere * shakeAmount;
|
||||
tempShakePosition.z = -10f; // lock z from shaking...
|
||||
camera.transform.localPosition = tempShakePosition; //
|
||||
shakeTimeAmount -= Time.deltaTime * decreaseFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
shakeTimeAmount = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
Assets/Scripts/CameraShake.cs.meta
Normal file
12
Assets/Scripts/CameraShake.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 015d8005b8f2f454da584e55b55711f5
|
||||
timeCreated: 1460231903
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -957,6 +957,7 @@ GameObject:
|
||||
- 92: {fileID: 1945693980}
|
||||
- 124: {fileID: 1945693979}
|
||||
- 81: {fileID: 1945693978}
|
||||
- 114: {fileID: 1945693983}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
@ -1031,3 +1032,17 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
--- !u!114 &1945693983
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1945693977}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 015d8005b8f2f454da584e55b55711f5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
shakeTimeAmount: 2
|
||||
shakeAmount: 0.6
|
||||
decreaseFactor: 1
|
||||
|
||||
@ -4,4 +4,6 @@
|
||||
EditorBuildSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Scenes: []
|
||||
m_Scenes:
|
||||
- enabled: 1
|
||||
path: Assets/_Scenes/Main.unity
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user