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