コード例 #1
0
ファイル: JuicyCameraShaker.cs プロジェクト: mmeiburg/juicy
        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
            });
        }