Squash and Stretch
Part of the Game Feel section of Coddy's Godot journey. Lesson 18 of 23.
Cartoons squash a character when it is hit, then let it spring back. This makes the hit look heavy.
A squash is a tween with two steps on scale. The first makes the robot wider and flatter. The second springs back to Vector2(1, 1) with Tween.TRANS_ELASTIC, which goes past the normal size and wobbles before it settles.
var wobble = create_tween()
wobble.tween_property(self, "scale", Vector2(1.4, 0.6), 0.08)
wobble.tween_property(self, "scale", Vector2(1, 1), 0.5).set_trans(Tween.TRANS_ELASTIC).set_ease(Tween.EASE_OUT)This is a second tween, next to the flash tween. Two tweens can run side by side when they change different properties.
Challenge
EasyAfter the flash in hit(), make a second tween called wobble:
- tween
scaletoVector2(1.4, 0.6)in 0.08 seconds, - then tween it back to
Vector2(1, 1)in 0.5 seconds withTween.TRANS_ELASTICandTween.EASE_OUT.
Try it yourself
extends Node2D
func hit():
modulate = Color(4, 4, 4)
var tween = create_tween()
tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Game Feel
Practice on your own: Godot playground