Overview
In action games, the "feedback" when the player hits an enemy or takes damage is a crucial element that greatly affects the game's satisfaction. One of the simplest yet most effective techniques for this feedback is the white flash - where a character briefly glows white.
In Godot, you can implement this white flash effect surprisingly easily with just one line of code and a Tween node, without any complex shader knowledge. The key is the modulate property.

What is the modulate Property?
modulate is a property held by all 2D nodes that inherit from CanvasItem (Sprite2D, Label, ColorRect, etc.). By setting a Color to this property, you can change the hue of that node (and all its children) through color multiplication.
modulate = Color(1, 1, 1)(white): Same as original color (default)modulate = Color(1, 0, 0)(red): Non-red components removed, appears reddishmodulate = Color(0.5, 0.5, 0.5)(gray): Overall darker
An interesting feature of modulate is that color values can exceed 1. Normally, colors range from 0 (black) to 1 (original color), but setting modulate values above 1 makes the sprite glow like HDR (High Dynamic Range), creating a blown-out appearance. This is the principle behind the white flash.
Setting modulate = Color(10, 10, 10) makes the sprite glow almost pure white.
Implementation: Smooth Transitions with Tween
A white flash involves "briefly turning white, then quickly returning to normal." Godot's Tween feature makes implementing such time-based animations very easy.
Here's an example function that applies a white flash to a damaged character (a node with a Sprite2D):
# Function called when taking damage
func take_damage():
# ... HP reduction processing, etc. ...
# Start white flash processing
flash_white()
# Function that executes white flash
func flash_white():
# 1. Instantly make the sprite white
$Sprite2D.modulate = Color(10, 10, 10) # Large values make it glow white
# 2. Create a Tween to smoothly return to original color
var tween = create_tween()
# Over 0.2 seconds, change $Sprite2D's modulate property to Color(1, 1, 1)
tween.tween_property($Sprite2D, "modulate", Color(1, 1, 1), 0.2)
Code Explanation
-
When
flash_whiteis called, first set$Sprite2D.modulateto aColorwith very large values. This instantly makes the sprite glow white. -
Next, create a new
Tweenobject withcreate_tween(). -
tween.tween_property()is the core of the animation. This method takes four arguments:- Target object:
$Sprite2D - Target property:
"modulate"(specified as string) - Final value:
Color(1, 1, 1)(original color) - Duration (seconds):
0.2
- Target object:
This schedules an animation that "changes $Sprite2D's modulate property back to white (Color(1,1,1)) over 0.2 seconds." The Tween plays automatically and is automatically disposed when complete, so that's all you need.
Summary
Combining the modulate property with Tween enables surprisingly easy implementation of professional-looking damage effects. This white flash gives players clear feedback that "the attack connected," greatly enhancing game satisfaction.
modulate: Changes color. Values above 1 create a white glowTween: Smoothly changes properties over time
This technique can be applied not just to damage effects, but also to sparkle effects when picking up items, aura effects when powering up, and various other situations.