material disappears when changing X scale in 2D game
I'm attempting to add a Charge move (think mega man mega buster) to my 2D, sprite-based game. The way it works right now is when the button is held down, a coroutine starts that rapidly changes the materials of the character sprites from normal sprite-default to a Standard material set to the Fade rendering mode. When the button is released, the coroutine stops and the material is reset.
This works great, except when I turn the character to go left, the sprite becomes invisible during the frames it is set to the Standard Fade Material, but is still visible with the Default material, so it looks like it's flashing in and out of existence.
It still works just fine if I turn right. The sprites that are being affected are child objects of the character parent. So the local scale of the sprites remains 1, but as soon as the parent object is x = -1, we have the disappearing. It reappears just fine if I turn back to go right after going left. And it does not matter which direction I'm facing when I first do it at runtime.
I'm not that familiar with materials and just played around with them until I found something that looked right, so it's likely there's a setting I don't know about, or just things about materials I'm not aware of. I hope?
Note: this seems like the best way to do this. I can't do it with sprites of different colors because I have multiple characters, multiple sprites that need to flash per character, and it should also continue during every animation. But I am open to other ways to get the effect.
Also, I have done something similar that was successful by having entities flash white using a GUI/text shader, and using that material with my charge move works. But I need a shader that won't totally block out the design of the character and allow me to lighten it and change color.
Why is this happening, and what can I do about it? Thanks for reading!
Your answer