Hit feedback
- Game Development course
- Advanced
- Lesson 63/71
- 4 min
Learn impact feedback with color and effects at collision.
Hit Flash
Flashing a sprite or model material bright white for a split second (e.g. 0.1 seconds) upon taking damage is called Hit Flash.
// Momentarily tinting white on damage
spriteRenderer.color = Color.white;This distinct burst unmistakably registers to the player that a projectile or melee strike connected.
Hit Stop (Freeze Frame) and Particles
Freezing game time for roughly 0.05 seconds on heavy impacts (Hit Stop) imparts tangible weight to combat. Counting elapsed time during this freeze requires WaitForSecondsRealtime.
IEnumerator HitStop(float duration) {
Time.timeScale = 0f;
yield return new WaitForSecondsRealtime(duration);
Time.timeScale = 1f;
}Bursting spark particles simultaneously at the impact point elevates the visual impact dramatically.
Practice Hit flash color check
Define a Start method. Inside, declare string flashRengi = "Kirmizi"; and print "Vurus parlama rengi: " + flashRengi to the console.
Starter code
using UnityEngine;
public class HitFeedbackTester : MonoBehaviour
{
// Start icinde flashRengi tanimla ve yazdir
}Sample solution
using UnityEngine;
public class HitFeedbackTester : MonoBehaviour
{
void Start()
{
string flashRengi = "Kirmizi";
Debug.Log("Vurus parlama rengi: " + flashRengi);
}
}Expected output
Vurus parlama rengi: Kirmizi
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the technique called that momentarily tints a material white or red to indicate an enemy took damage?
- NavMesh Bake
- Audio Reverb
- Lobby Matchmaking
- Hit Flash Correct answer
Explanation: Hit Flash momentarily colors the damaged entity in a stark tint to confirm successful hit registration.
2 Realtime delay yield
yield return new ____(duration);
yield return new WaitForSecondsRealtime(duration);
Explanation: To yield inside a Coroutine while Time.timeScale is zero, 'WaitForSecondsRealtime' is required.
3 Hit feedback concepts
| Term | Meaning |
|---|---|
Hit Flash |
Instant character flash on damage |
Hit Stop |
Freeze conveying weight of impact |
WaitForSecondsRealtime |
Delay unaffected by time scale |
ParticleSystem |
Spark burst spawned at collision point |