How to make the pixels of an object that are obscured by a specific object transparent Unity2D

Hello, I was wondering how to make pixels that are obscured by an object transparent. I guess that a less vague way of putting this is making a "Hole" object that creates a transparent "Hole" in the object underneath it. I've made a few example images to further clarify

So for instance, in the picture above if I have 3 objects:

Object 1, the Hole, and Object 3

with the hole resting on top of Object 1 how could I achieve something like the picture below> I feel like the correct way of doing this would be through shaders, but I am completely unexpirenced with shaders and have no clue where to start, espically since the documentation I looked through seemed to all be for 3D, and the answer I found for 2D shaders seemed too advanced to pick apart without experience.

1 Reply

So, add Mask Interaction to one object and add a mask, that shows the effect.

In your example, add a Mask Interaction to the large square, like in the picture below. Mask Interaction is the last item on the SpriteRenderer. For this effect, pick "Visible Outside Mask". Now it will be drawn unless a mask covers it.

Second, add a Sprite Mask ("The hole"). It needs to have a sprite of its own to show any effect. Put it in the middle of the large square.