How can I dynamically make only a certain part of my sprite transparent? Through a Shader or something

1.3k views Asked by At

I have a sprite for my player character and would like to add a ghost effect to the sprite. I simply want to make a transparent version of the character. The issue is I have my player graphics split into different pieces to make animation easier so when I just simply increase the transparency of each piece of the sprite, you can obviously see the all of the sprites entirely.

I simply want to make all pixels behind the "body" of the player (the big black box) completely transparent. Any idea how I would achieve this?

Thanks to anyone who can help! :)

I just want a transparent version of this image.

enter image description here

1

There are 1 answers

0
JohnWayyyne On

Looks like I didn't know about Sprite Masks. Basically I just had to add a sprite mask to the player prefab and use the body sprite as the mask. Then I simply mark all of the "Mask Interaction" fields as "Visible Outside the Mask" for all objects displayed behind the body.

Here is unitys docs on it and here is what is looks like https://docs.unity3d.com/Manual/class-SpriteMask.html

enter image description here