Menu
CoddyTech

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 icon

Challenge

Easy

Squash the robot when it is hit.

  1. After the flash in hit(), make a second tween called wobble.
  2. Tween scale to Vector2(1.4, 0.6) in 0.08 seconds.
  3. Then tween it back to Vector2(1, 1) in 0.5 seconds with Tween.TRANS_ELASTIC and Tween.EASE_OUT.

Press Play and press E: the robot flattens and springs back. Then Check.

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)

All lessons in Game Feel

Practice on your own: Godot playground