How can I create a hit effect by changing the alpha value of material of GameObject?

I was making a runner game in Unity and was implementing the interaction when the player collided with a static obstacle. I want to make the character fade back and forth for 2 seconds after the collision and lose some health. To do this after the collision I am calling this coroutine:

void ChangeAlphaValue(float alpha)


Color newCol = material.color;
        newCol.a = alpha;
        material.color = newCol;


It is pretty dumb but it is not the case. The problem is the alpha value is only changed when the rendering mode of the material is transparent and when it is, the character does not fade away but only be transparent.

How can I make the effect by material or in any way?

Greetings @mfzenbilci. Change the Rendering Mode to “Fade” and you should get what you want.