Print

Manual

Quick Start

Let’s add blinking effect to our game object.

In the knight demo we have game object with sprite renderer.

Now we need to add DamageEffectScript component on the same game object where sprite renderer is.

As you can see now we need to set blinking material

You can select one of preset ones, or custom made. We want to use it on 2d sprite, that means we need to select from materials that are represented as sprites, not as spheres. Note that preset 3d materials have “3D” postfix in their names.


As another option you can just drag’n’drop material you like from the directory
Assets/DamageEffect/Materials where they are conveniently placed in separate folders.

Now all we need is to add script that triggers blinking effect

Not much to explain here except for the Blink method.

Blink method accepts two parameters: first is delay before blinking in seconds, second is duration of blinking.

Well, that’s it!

If you have any questions/suggestions don’t hesitate to say hi on Unity forums, and if you want to go directly to fresh docs click this big blue mystery book.

FAQ

Q: Where are my shadows?

A: Use DamageShader3D_UnityLambertBase AKA DamageBlink3D_UnityShadows

Q: How exactly does blinking script work?

A: Blinking script is fairly primitive. It seeks all the renderers down the hierarchy, saves current materials, replaces current materials with blinking materials and starts coroutine with delay. When coroutine ends it restores old materials to respective renderers.

Q: Blinking script doesn’t work. What can be the cause?

A: The issue can be that materials don't restore. That can happen if old materials weren't available on Start event. Also it could happen if coroutine was interrupted, it usually happens when gameObject with coroutine was disabled/enabled during the coroutine execution, it kills current coroutines. For concrete cause I'd debug the blinking script and check what happens with old materials in BlinkCoroutine.

Leave a Reply