void LateUpdate()
{
camOriginalPos = cam.transform.localPosition;
camNewPos = camOriginalPos;
camNewPos.z = -10f;
//Debug.Log("Player Distance (Mag): " + playerDistance.magnitude);
//Debug.Log("Shake Trigger: " + shakeTrigger);
if (playerDistance.magnitude <= shakeTrigger && player.isAlive && speed > 0)
{
//cause vibration on mobile
/*
#if UNITY_IPHONE || UNITY_ANDROID
if (PlayerPrefs.GetFloat("Vibrate") == 1 && (playerDistance.magnitude <= shakeTrigger/2))
{
Handheld.Vibrate();
}
#endif
*/
//Calculate the X position of the next camera position
camNewPos.x = camOriginalPos.x + (Random.insideUnitSphere.x*shakeIntensity);
//Calculate the Y position of the next camera position
camNewPos.y = camOriginalPos.y + (Random.insideUnitSphere.y*shakeIntensity);
//Move the camera to the new location
camTransform.localPosition = camNewPos;
}
}