예제 #1
0
        public static JuicyCameraShaker Instance(Camera camera)
        {
            if (instance != null)
            {
                return(instance);
            }

            if (camera.TryGetComponent(out JuicyCameraShaker shaker))
            {
                return(instance);
            }

            instance                  = camera.gameObject.AddComponent <JuicyCameraShaker>();
            instance.target           = camera;
            instance.originalPosition = camera.transform.position;

            return(instance);
        }
예제 #2
0
        private void PerformShakeDelayed()
        {
            float shakePower = 1f;

            if (useRangeMultiplier.isActive)
            {
                float distance   = Vector3.Distance(transform.position, camera.Value().transform.position);
                float distance01 = Mathf.Clamp01(distance / useRangeMultiplier.range);
                shakePower = (1 - Mathf.Pow(distance01, 2)) * useRangeMultiplier.maximumPower;
            }

            JuicyCameraShaker.Instance(camera.Value()).Shake(new JuicyCameraShaker.ShakeProperties {
                power           = shakePower,
                ignoreTimeScale = timing.ignoreTimeScale,
                smoothness      = smoothness,
                duration        = timing.duration,
                maximumStrength = maximumStrength,
                frequency       = frequency,
                falloffCurve    = ease.curve,
                recoverySpeed   = recoverySpeed
            });
        }