Material color change without being seen?

I have a game object with multiple tiles within it. Each tile has trigger event to catch when they are colliding with something. The point of this is to give the visual cue of a grid that displays to the player where they can or cannot build on the grid; based on the color that changes in the trigger enter/exit events. In the triggers, I adjust the material’s color to give the desired effect. As the camera moves, I move the parent game object so that the grid effectively remains on screen at all times without using too much cpu/memory.

My problem is that when I move the grid and a tile that was previously changed to the color red due to its collision, it changes back to blue because the exit event tells it to. There is a very ugly flash because the material change happens after it moves. How can I change the material color without causing it to flicker? I was hoping that by using the Renderer.enabled property I could hide it, change the color, then show it, but it seems that when I try setting the enabled flag back to true, it doesn’t reshow it.

renderer.enabled = false;
renderer.material.color = (collisionCount == 0) ? validColor : invalidColor;
renderer.enabled = true;

I have considered and tried using a fade to the other color, that also doesn’t look right. I was hoping others have had similar experiences and could give me some ideas or something I’m unaware of.

Thanks,

Jacob
Starleaf Labs

You can animate the material color every frame without any flicker.

Enabling/Disabling is more likely to cause a flicker than changing the color.

Does anything else give a similar flicker? particle systems?

I’m currently animating the colors already by fading between them with a short duration. It does the trick to make it less harsh, but it still doesn’t give me the effect I want. What I’m going for is a grid that appears to be endless, but because the grid is effectively attached to the camera it will move and cause each of the tiles’ triggers to fire when they leave collided space.

I think using a particle system is kinda overkill for what I need. And I don’t see it working for the desired effect.

Thanks for the suggestions though!

Jacob
Starleaf Labs