using UnityEngine; using System.Collections; public class CameraShake : MonoBehaviour { public Transform camTransform; public float shake = 0f; public float shakeAmount = 0.7f; public float decreaseFactor = 1.0f; Vector3 originalPos; void Awake() { if (camTransform == null) { camTransform = GetComponent(typeof(Transform)) as Transform; } } void OnEnable() { originalPos = camTransform.localPosition; } void Update() { if (shake > 0) { camTransform.localPosition = originalPos + Random.insideUnitSphere * shakeAmount; shake -= Time.deltaTime * decreaseFactor; } else { shake = 0f; camTransform.localPosition = originalPos; } } }
Saturday, June 14, 2014
Camera Shake C# Unity3d
Subscribe to:
Post Comments (Atom)
Popular Posts
-
C# Unity has support for Getter and Setter properties which is very important in terms of Object Oriented Programming, Here is a simple ex...
-
Here easy steps are shown to create Windows Installer (formerly knows as Microsoft Installer ) for your Unity game, Tool to Use: Inno S...
-
By default Unity doesn't serialize Dictionary, So it is not possible to show key/value pair directly in Unity3d inspector ....
No comments:
Post a Comment