In my game, I have a car scene (object) which then gets instantiated during gameplay many times. Each car has a separate state for its breaks, and when the car is breaking, I want its tail lights to change their emission strength.
How should this be done properly in Godot?
The way I'm currently doing this in the game is that, in a script for the tail lights, I call
material = material.duplicate() to make a unique material for the car. Then in the process function, I change the material's emission as necessary using
material.emission_strength. This feels like it isn't the proper way to go, and I expect it to not be performant to duplicate the material each time a new car is spawned. How can this be improved?