Skip to content

Possible to transition Tween.Shake to a small/bigger shake with ease smoothly? #56

Answered by KyryloKuzyk
doot56 asked this question in FAQ
Discussion options

You must be logged in to vote

Hey, thanks for a great question!

Animations with undefined duration is typically not a good fit for a tween library.

It is possible to achieve this effect with a tween library, but the code will not look pretty :)
In this code snippet I use Tween.ShakeCustom() and multiply the shakeVal by a currentShakeStrength. Then I animate currentShakeStrength to fade in/out the shake.

Tween shakeStrengthTween;
Tween shakeTween;
float currentShakeStrength;

void Update() {
    if (Input.GetMouseButtonDown(0)) {
        shakeStrengthTween.Stop();
        if (shakeTween.isAlive) {
            // Animate shake strength to 0f, then stop the shake
            shakeStrengthTween = AnimateShakeStrength(0f)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by KyryloKuzyk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
FAQ
Labels
None yet
2 participants