I'm looking for code that will make an enemy unit flash when hit for a secind and then return it to it's normal color.
var colors = new Color[2];
function OnCollisionEnter() {
renderer.material.color = colors[0];
yield WaitForSeconds(.5);
renderer.material.color = colors[1];
}
Drop this on your object. You will be able to define the color it flashes (color 0) and the non flashing color (color 1) in the Editor with the standard color picker. Make sure color 1 and your material color are the same, or it will look wrong.
Something like this?
I attempted that but for some reason the code didn't work. In addition that code works on the assumption that collideColor variable has been set up, but seeing as that's not included, I can't imitate it.