So I have a bunch of cubes instantiated. Each time the player hits one of these cubes (which is quite often) they change their color to match that of the player. What would be a performant way to do this? So far i am doing this on OnTriggerEnter then grab my player’s mesh renderer, get its material and get the color. This is quite an expensive process. I was wondering if there is any better way. The cubes do not move by the way, so if they can somehow be batched as well that would be a plus! Also, the player’s color is random.
I would add a static refrense to the color in the player, something like:
public static Color publicColor (keep in mind to update this color as well) and when any cubes want to chage color they just say
meshrenderer.material.color = myPlayer.publicColor If you want a performance boost, but also keep in mind that this will only work with 1 player.