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
Labels:
camera shake unity3d
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Here are some of important facts of Unity3d Coroutines which might help you, 1. You can only stop Coroutines that are invoked u...
-
Hello developers, As a mobile app/game developers it is not quite easy to make app/game UI same on different resolution devices, In previ...
-
As a mobile game/app developer it is headache to port game/app to various mobile/hand held devices having different resolutions. Here is th...
No comments:
Post a Comment