Ejemplo n.º 1
0
        /// <summary>
        /// This is the internal shake function.  Called symbollically using the MakeMeShake function, this is required when wanting to stop a coroutine (using StopShake).
        /// </summary>
        /// <param name="props">Shake properties for the specific shake.</param>
        /// <returns>Coroutine.</returns>
        private IEnumerator Shake(CameraShakeProperties props)
        {
            float timer = 0;

            while (timer <= props.duration)
            {
                float normalizedDistanceToShakeOrigin = 1 - (Mathf.Clamp(Vector3.Distance(transform.position, props.OriginatingPosition), 0, maxAffectedDistance) / maxAffectedDistance);
                float amplitude = props.envelope.Evaluate(timer / props.duration) * props.amplitude * normalizedDistanceToShakeOrigin;

                DirectShake(props.frequency, amplitude);

                timer += Time.deltaTime;
                yield return(null);
            }
        }
Ejemplo n.º 2
0
 public void MakeMeShake(CameraShakeProperties props)
 {
     StartCoroutine("Shake", props);
 }