"Hit" style tweens?

Godot Version

4.3

Question

Hi all,

Just wondering if there’s a way to get a hit style tween where the object animates but the end value is the same as the start.
Another example might be a shake?

This is the best I have at the moment and I was wondering if i’m missing something.

		Tween tween = target.CreateTween();
		tween.TweenProperty(target, "scale", Vector3.One * 1.5f, 1.0f)
			.SetCustomInterpolator(Callable.From<float, float>(t => punch.Sample(t)))
			.SetDelay(0.5f);

Nov-27-2024 08-22-02
Here, the Tween works but gets forced to the end value.

Any ideas?
Thanks!
Pete

1 Like

Have you tried any of the .setTrans options for your tween? Like BOUNCE.

Hey thanks, but that ends up with a different end value so it’s not the effect I was looking for.


Here’s the result -
Nov-27-2024 12-16-49

1 Like

Have you tried adding another tween property line to set it back to the original value? Probably a couple different ways using this method. You’d have to store the original value somewhere at an appropriate time e.g. right before the first tween property.

1 Like

@Petey Set back to original size at end with no time duration

Tween tween = target.CreateTween();
		tween.TweenProperty(target, "scale", Vector3.One * 1.5f, 1.0f)
			.SetCustomInterpolator(Callable.From<float, float>(t => punch.Sample(t)))
			.SetDelay(0.5f);
        tween.TweenProperty(target, "scale", Vector3.One, .0f);
1 Like

Yay! Got something working, thanks so much for that :grinning:
Nov-28-2024 11-46-36

2 Likes