Blink the player after a hit and end visible when protection ends
After a hit the hero flickers while protected. Done carelessly, the hero ends the protection invisible, gets hit again during it and restarts the timer, or flickers at a speed that depends on the screen. Here is the timing that ends cleanly.
Why this works
Blinking tells the player the hit is over and they have a moment to get away, so it is the same clock as the protection, not a separate effect. Computing visibility from time alone guarantees the character ends up visible and the blink runs at the same speed everywhere.
When not to use it
Don't use it when taking a hit should be costly in a row, such as in a game where constant pressure is the point, or where damage over time keeps ticking. Protection from every hit would make the player unbeatable. Use a short flash instead.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 18 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Blink the player after a hit and end visible when protection ends" (read_entry damage-blink-ends-visible-and-does-not-restart) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP