As far as I know, there's no proper way to do this for DOTween's DOShake methods (though I would love to be corrected). One really hacky way to do this is by setting the duration to a low-ish value, and re-initializing the tween with different values in it's OnComplete callback. It's pretty far from ideal, since you're not changing the values during the tween, but rather at an interval - resulting in a stepped or sudden change. Resource-wise, I don't imagine this being very efficient either.
Tweener shakeTween;
TweenCallback shakeTweenComplete;
void Start()
{
shakeTweenComplete = () =>
{
shakeTween = transform.DOShakeRotation(0.1f, strength: shakeStrength, vibrato: shakeVibrato, fadeOut: false).SetRelative();
shakeTween.OnComplete(shakeTweenComplete);
};
// Invoke the callback instead of having duplicated code
shakeTweenComplete.Invoke()
}
I have shakeVibrato
modified elsewhere. I also tried to do this with SetLoop and OnStepComplete, with no luck.
EDIT - For future reference, this is my take on how OP ended up solving this issue. I substituted changing the vibrato with Tweener.timeScale
, since it ends up looking the same anyway.
public float shakeMultiplier = 1.0f;
public float shakeTimeScale = 1.0f;
// These values won't be changed
public float baseShakeDuration = 1.0f;
public float baseShakeStrength = 0.1f;
public int baseShakeVibrato = 10;
Vector3 shakePosition;
Tweener shakeTween;
void Start()
{
shakeTween = DOTween.Shake(() => shakePosition, x => shakePosition = x, baseShakeDuration, baseShakeStrength, baseShakeVibrato, fadeOut: true)
.SetLoops(-1, LoopType.Restart);
}
void Update()
{
transform.localPosition = shakePosition * shakeMultiplier;
shakeTween.timeScale = shakeTimeScale;
}