public void ShakeCamera(Types type, TypesAxis _axis = TypesAxis.All) { if (!debugMode) { switch (type) { //case Types.HARD: ShakeCamera(HARD_AMOUNT, HARD_DURATION, true, HARD_SMOOTH); break; //case Types.MID: ShakeCamera(MID_AMOUNT, MID_DURATION, true, MID_SMOOTH); break; //case Types.LOW: ShakeCamera(LOW_AMOUNT, LOW_DURATION, true, LOW_SMOOTH); break; //case Types.None: ResetCamera(); break; //default: throw new System.NotSupportedException(); case Types.HARD: ShakeCamera(HARD_SHAKE_AMOUNT, HARD_SHAKE_DURATION, HARD_SHAKE_FORCE, _axis); break; case Types.MID: ShakeCamera(MID_SHAKE_AMOUNT, MID_SHAKE_DURATION, MID_SHAKE_FORCE, _axis); break; case Types.LOW: ShakeCamera(LOW_SHAKE_AMOUNT, LOW_SHAKE_DURATION, LOW_SHAKE_FORCE, _axis); break; case Types.None: ResetTweening(); break; } } else { ShakeCamera(amountShake, durationShake, forceShake); } }
public void ShakeCamera(float amount, float duration, TypesAxis axis = TypesAxis.All) { shakeAmount += amount; //Add to the current amount. startAmount = shakeAmount; //Reset the start amount, to determine percentage. shakeDuration += duration; //Add to the current time. startDuration = shakeDuration; //Reset the start time. if (!isRunning) { StartCoroutine(Shake()); //Only call the coroutine if it isn't currently running. Otherwise, just set the variables. } }
public void ShakeCamera(int amount, float duration, Vector3 force, TypesAxis _axis = TypesAxis.All) { if (DOTween.IsTweening(ID_CAM_TWEEN)) { DOTween.Kill(ID_CAM_TWEEN); } //if (_axis == TypesAxis.AxisX) force = new Vector3(force.x, 0, 0); //if (_axis == TypesAxis.AxisY) force = new Vector3(0, force.y, 0); if (_axis == TypesAxis.AxisX) { force = new Vector3(0, force.x, 0); } if (_axis == TypesAxis.AxisY) { force = new Vector3(force.y, 0, 0); } transform.DOShakeRotation(duration, force, amount).SetEase(Ease.InOutQuad).SetId(ID_CAM_TWEEN).OnComplete(() => { transform.localRotation = Quaternion.identity; }); }