Camera Shake

Author: Daniel Moore (Firedan1176)

Description
This script offers a simple Camera Shake effect with a given time and amount. The script does not affect the transform of the main Camera (or any Camera), so this script should work with any Character Controller, even with Unity 5's.

Usage
Place this script on a parent gameobject of the main camera, or any camera. The shake effect can be triggered at any point with the preset values, or you can pass in an amount and a duration, which will be added to the current. To pass values via another script, use:

Special Controller
If you are using a Character Control which makes the camera parent rotate on Y and you don't want to reset the rotation when a shake occurs, just replace at the end of the Shake Coroutine :

transform.localRotation = Quaternion.Euler (rotationAmount);

by

transform.localRotation = transform.localRotation * Quaternion.Euler (rotationAmount);

And :

transform.localRotation = Quaternion.identity;

by

transform.localRotation = Quaternion.Euler(0.0f, transform.localRotation.eulerAngles.y, 0.0f);