Each time I play the game in engine it creates a new MID for each object I have the component on. If I stop playing and start again it makes another one.
Does this have any performance impacts? I don’t really know how much of this works as I’m new to game development.
The component is for a transparency system to hide objects between player and camera, it swaps to the material and scales its opacity down over time and replaces it with its old material when needed.
You might try using the Tick function to check a Boolean variable (yes or no) of sorts in a Branch node, and if True, rather than creating a dynamic material instance, you could set the dynamic material instance, if false set to another. If you wanted to go a step further, you could create two variables, one for each dynamic material instance you want, that way you can change them on the go and access them easier.
It has no impact. If you restart the editor, the extra indexes will be reset.
If you do not store your MID in a variable and it is no longer assigned to a mesh, it will be Garbage Collected. Structs are excluded as they’re not UObjects.