Menu
CoddyTech

Flash on a Hit

Part of the Game Feel section of Coddy's Godot journey. Lesson 16 of 23.

A white flash shows the player at once that something was hit.

modulate multiplies the node's colors. Color(1, 1, 1) changes nothing, so it is a node's normal value. Numbers above 1 make the colors brighter. Color(4, 4, 4) makes the robot almost white.

modulate = Color(4, 4, 4)

Then tween modulate back to Color(1, 1, 1). The robot fades back to its own colors in a fraction of a second.

In this game, pressing E calls the robot's hit() function.

challenge icon

Challenge

Easy

Flash the robot when it is hit.

  1. In hit(), set modulate to Color(4, 4, 4).
  2. Then tween modulate back to Color(1, 1, 1) in 0.3 seconds.

Press Play and press E: the robot flashes white and fades back. Then Check.

Try it yourself

extends Node2D

func hit():
	pass

All lessons in Game Feel

Practice on your own: Godot playground