How to Make a Sprite Flash White When Hit in Unity
A sprite flashes white when its shader blends every pixel toward white for a moment and then back. Unity’s default sprite shader cannot do that: a SpriteRenderer’s Color multiplies the texture, so it can darken or tint a sprite but never make it brighter than it is. A hit flash needs a shader with a flash colour and an amount you move from 1 back to 0 in about a tenth of a second.

Why tinting the sprite cannot flash it white
Section titled “Why tinting the sprite cannot flash it white”The colour you see is the texture’s colour times the renderer’s Color. White in the Color field leaves the sprite as it is, and every other value makes it darker or tints it. So setting spriteRenderer.color = Color.white on a hit does nothing, and Color.red gives a red tint rather than a flash.
Without a shader, the two usual workarounds are:
- A white frame in the animation: an all-white copy of the sprite, played for a frame or two. It costs one extra frame per sprite and an animation event per hit.
- A white silhouette on top: a child sprite with the same shape in white, switched on for the flash. It costs a second sprite per enemy, and it has to follow every frame of the animation.
A flash shader by hand
Section titled “A flash shader by hand”In Shader Graph, make a Sprite Unlit graph (or Sprite Lit, under URP’s 2D Renderer) and add two properties: a Flash Color and a Flash Amount slider from 0 to 1. Then:
- Sample Texture 2D with
_MainTex. - A Lerp from its colour to Flash Color, with Flash Amount as T, into Base Color.
- The texture’s alpha into Alpha, so the flash keeps the sprite’s shape.
There is no need for a Vertex Color node: URP’s sprite targets multiply the graph’s result by the renderer’s Color on their own, so a Vertex Color node would apply it twice. It also means the Color tints the flash: only a renderer whose Color is white flashes pure white.

Then a script moves Flash Amount. To flash one enemy and not every enemy with the same material, set it through a MaterialPropertyBlock, which gives this renderer its own value without making a new material:
using System.Collections;using UnityEngine;
public class FlashByHand : MonoBehaviour{ private static readonly int FlashAmount = Shader.PropertyToID("_FlashAmount");
[SerializeField] private float duration = 0.12f;
private SpriteRenderer sr; private MaterialPropertyBlock block;
private void Awake() { sr = GetComponent<SpriteRenderer>(); block = new MaterialPropertyBlock(); }
public void Flash() { StopAllCoroutines(); StartCoroutine(FlashRoutine()); }
private IEnumerator FlashRoutine() { for (float t = duration; t > 0f; t -= Time.deltaTime) { SetAmount(t / duration); yield return null; } SetAmount(0f); }
private void SetAmount(float amount) { sr.GetPropertyBlock(block); block.SetFloat(FlashAmount, amount); sr.SetPropertyBlock(block); }}The property’s Reference in Shader Graph has to match the name in the script, here _FlashAmount.

With All In 1 Sprite Shader’s Hit Effect
Section titled “With All In 1 Sprite Shader’s Hit Effect”Don’t own it yet? → Get it on the Unity Asset Store
Add the AllIn1Shader component to the sprite (Add Component → AllIn1SpriteShader → AddAllIn1Shader) and tick Hit Effect in the material’s Color Effects. It blends the sprite toward Hit Effect Color times Glow Intensity by Hit Effect Blend:

- Hit Effect Color (
_HitEffectColor) is the flash colour, white by default. - Glow Intensity (
_HitEffectGlow) multiplies it, from 1 to 100, 5 by default. Above 1 the flash is brighter than white, which only shows as a halo with Bloom; without Bloom it looks plain white. See How to Make a Sprite Glow. - Hit Effect Blend (
_HitEffectBlend) is how much of it shows, from 0 to 1. It is 1 by default, so the sprite turns white the moment you tick the effect: set it to 0 for the resting state.

Leave the effect on and move only the blend. That way the shader never has to switch variants in the middle of a fight, as How to Enable/Disable Effects at Runtime explains. Scripting has a complete flash script, the one recorded at the top of this page, and How to Animate Effects covers the Animation window and DOTween:
mat.DOFloat(0f, "_HitEffectBlend", 0.12f).From(1f);When the flash is not white
Section titled “When the flash is not white”Hit Effect is applied before Gradient, Contrast and Brightness, Color Swap, Color Ramp, Change 1 Color, Posterize, Hue Shift and Overlay in the shader. If any of those is on, it works on the flash too: a Color Ramp turns the white into the ramp’s brightest colour and loses the glow, and a Change 1 Color whose target is white replaces the flash with its new colour.
Two ways out:
- Turn the other effect down for the flash. Color Swap and Color Ramp have a Blend slider (
_ColorSwapBlend,_ColorRampBlend); move it to 0 while Hit Effect Blend is up. Change 1 Color has no Blend slider, so for it use the second way. - Move Hit Effect below them in the shader. In
AllIn1SpriteShader.shader, cut the block that starts with#if HITEFFECT_ONand containscol.rgb = lerp(col.rgb, _HitEffectColor.rgb * _HitEffectGlow, _HitEffectBlend);, and paste it just above the line//OUTLINE-------, after Hue Shift and Overlay. The flash then covers every colour effect. Each shader variant has its own copy of the block: the Scaled Time and UI Mask shaders in their own files, the URP 2D Renderer and SRP Batcher variants inShaderLibrary. An update of the asset puts it back, so note it somewhere.

One enemy flashes, not all of them
Section titled “One enemy flashes, not all of them”Every sprite with the same material shares it, so a change made through sharedMaterial flashes all of them at once. Three ways to flash one:
renderer.material, which makes this renderer its own copy the first time you touch it. Simple, and the copy lives until the object is destroyed. See material or sharedMaterial.- A
MaterialPropertyBlock, as in the script above, with_HitEffectBlendin place of_FlashAmount. No copy is made, and it works on any renderer. It does not work on UI Images. - A material per enemy type, made in the editor, if each type flashes as a group anyway.
The AllIn1Shader component makes a new material for each object you add it to in the editor, and keeps it in the scene until you save it (Saving Prefabs). Once a saved material is on many prefabs, they share it.
Characters made of several sprites
Section titled “Characters made of several sprites”A character built from separate body parts has one renderer per part. To flash it as one, give the script an array of the parts’ renderers and set the blend on each, with material or a property block. A single shared material for all the parts, moved through sharedMaterial, also flashes them together, but it flashes every other character using that material as well.
UI Images
Section titled “UI Images”Hit Effect works on a UI Image too, with three differences:
- UI materials are shared by every Image that uses them, and the Animator cannot animate them. Give the Image its own material on
Awakeand drive it from code or DOTween (UI Images, UI materials cannot use the Animator). - On a Screen Space Overlay canvas the flash shows but never glows, because Bloom does not reach that canvas (why). If the Image disappears altogether instead, something is writing over the depth buffer: set Z Test Mode to Always in the material’s Advanced Configuration and keep Depth Write off, its default (Builds and devices).
- Inside a Mask or Scroll View, write to
image.materialForRendering, notimage.material.
The same flash on 3D models and in your own graphs
Section titled “The same flash on 3D models and in your own graphs”The All In 1 3D Shader has the same effect, called Hit, with Hit Color, Hit Glow and Hit Blend. All In 1 Shader Nodes has a Hit node for your own Shader Graphs.
What it does not do
Section titled “What it does not do”- Flash on its own. Hit Effect has no timer: something has to move Hit Effect Blend, a script, an animation or a tween.
- Flash a UI Image through the Animator. UI materials are shared, so Unity does not let the Animator animate them.
