- Home /
How to make an object glow without also changing other objects using same material?
I'm shooting lasers at asteroids. The lasers "heat up" the asteroids, which explode if they get too hot. I want to make this clear to players without making them read an explanation or go through a tutorial, so I tried having the diffuse color value on an asteroid's shader increase its red component as the asteroid takes damage (and reduce as the asteroid cools down).
This looked great, except that every asteroid using the same material also got redder. I'm sure creating a new material for each asteroid is probably the wrong idea for performance, and even if it isn't I feel like the code would be messy and complicated - is there a more elegant way to achieve this effect, where some asteroids glow redder while others do not?
I think your answer is exactly the opposite of what I want, but from there I think I stumbled across the correct answer. I will try changing this:
https://docs.unity3d.com/ScriptReference/Renderer-material.html
Answer by BigScary · Nov 30, 2016 at 04:55 PM
The answer is to use MeshRenderer.material instead of MeshRenderer.sharedMaterial. However, using that means you have to do some cleanup on your own, and the API documentation is unclear. See this question for details.