Home Game Development unity – Clip a 2D sprite inside a bounding field with out masking

unity – Clip a 2D sprite inside a bounding field with out masking

0
unity – Clip a 2D sprite inside a bounding field with out masking

[ad_1]

In Unity, engaged on a 2D recreation, I’ve a platform recreation the place the platforms can “sink” when jumped on. The platforms are 32×32 sprites, and when sinking, the specified impact is to push the sprite down and keep away from drawing the portion of the sprite outdoors the unique 32×32 field:

alt text

I at the moment do that by putting a sprite masks beneath the platform. It works very properly, however the issue begins when I’ve a number of such platforms instantly beneath each other:

enter image description here

I am unable to get this impact utilizing masks because the masks may also partially cowl the higher facet of the platform beneath. An ad-hoc answer is assigning the sprites to completely different sorting layers, however I generally have many such platforms, they usually’re all conceptually the identical, so I’m on the lookout for a cleaner answer.

TL;DR: I need to outline a “bounding field” for a particular sprite such that components of the sprite outdoors the field won’t be drawn.

Note that this can be a 2D downside regarding sprites; I’ve seen answer based mostly on 3D parts which aren’t related right here.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here