コード例 #1
0
ファイル: CameraShake.cs プロジェクト: pitsikalis/GSS_Master
        /// <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);
            }
        }
コード例 #2
0
ファイル: CameraShake.cs プロジェクト: pitsikalis/GSS_Master
 public void MakeMeShake(CameraShakeProperties props)
 {
     StartCoroutine("Shake", props);
 }