Hide parts of sprites

Godot Version

4.5

Question

Hi! I have this guillotine sprite that goes up and down and i want to hide the parts that goes outside the machine. Do you have a modular way to do this? I expect to have more of these in the future.

You can use masking, here’s a simple way to do that first you have to draw a sprite that is white where you want to display your sprite and transparent where you want to make it not visible,Like this

and what you have to do is make a mask sprite like this

and make the guillotine sprite child of the mask sprite (It’s just a normal sprite) and enable Clip children on the mask sprite

Your scene tree should look like this
image

and if you have done everything correctly,your sprite should look like this!

Note:Your Blade’s mask sprite have to be a simple Box Just to hide the upper part

5 Likes

Thank you so much! i use polygon2D instead of a sprite :slight_smile:

1 Like

Still not a problem! it would still work with a polygon2D!