Hi everyone, I’m posting here because I want add a specific texture (A) on top of a sprite (B). To do this I modified a shader found on the internet, so that it takes the shape of my B sprite and shows only the parts of A that are inside B.
My problem is that if i have 2 sprites next to each other, their masks will afect the other sprite aswell.
So I’m looking for a way to affect only 1 sprite with my mask, maybe on the childs of a same gameObject ?
Maybe I’m misunderstanding your problem but I think it can be solved very easily by using the new Sprite Mask component with a custom range. I had trouble understanding how to use the Sprite Mask on multiple objects at first. But the custom range option lets you isolate the masking of sprites to a sorting layer so that you can keep different masked sprites on different sorting layers and not have them interfere with each other.
It’s not obvious right away that the custom range lets you have control over how the mask affects the sprites in your scene. Especially when you want multiple masks on different groups of sprites. But that’s exactly what its for. You just pick a sort layer for the range after selecting that option and that’s it.
If I’m understanding the problem correctly, and if it suits your needs, you can use Unity’s built in Alpha Mask UI component (UI Components - Unity Learn).
What you want to do with this is to add the Mask component on a child of the banana that has the banana sprite attached to it as well, and then child the blood splatter to that object.
The Mask component makes it so only pixels within the mask’s sprite are displayed, while all others are omitted.
This only affects children of the mask object.