Game Development Reference
In-Depth Information
Camera shake
Now, here's an effect we can achieve with the Unity free version: camera shake!
For fighting, shooting, and action games generally, a camera shake effect can be
important. It conveys impact, danger, action, dynamism, and excitement—a form
of kinetic feedback. It can, in fact, be used to stand in for lots of other animations
too that simulate a pervasive motion and emotion where there really isn't any to be
found elsewhere in the scene. To this extent, camera shakes can save us lots of work
by creating an overarching animation, as shown here:
Camera shake effects
There are many ways to create camera shakes, but all of them involve fluctuation of
the camera position between a minimum and maximum range using some kind of
"randomness" function. Sometimes, the "randomness" is left raw, and sometimes, it's
smoothened using the damping functionality to create a slower or more "lowing"
shake. Refer to the following code sample 5-10 that can be attached to any camera
to create a shake effect:
using UnityEngine;
using System.Collections;
//---------------------
public class CameraShake : MonoBehaviour
{
private Transform ThisTransform = null;
//Total time for shaking in seconds
public float ShakeTime = 2.0f;
 
Search WWH ::




Custom Search