0
\$\begingroup\$

Guys if I have two sprites placed on the same spot. How can I show the half of each Sprite instead of the one on top? The sprites are basic circles

All sprites have basic colors, no textures.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ There are lots of ways to choose which half to show. Can you include an image of the result you have in mind? \$\endgroup\$ – DMGregory Mar 19 at 10:24
  • \$\begingroup\$ Let us say the first circle is blue and the other is green. So it should form a blue|green circle \$\endgroup\$ – Joe Robert Mar 19 at 10:29
  • \$\begingroup\$ That's not an image. The trouble with text here is we can read "a blue/green circle" in more than one way. It could be a circle divided along a diameter (which one?), that's green on one side of the divide and blue on the other. Or it could be an undivided circle that's all one colour, a hue intermediate between green and blue. Or we could mix the green & blue in all sorts of other ways — smooth gradient blends, stripes, chequers, swirls... So we need some more information from you about what you're trying to do to ensure we give you useful answers. \$\endgroup\$ – DMGregory Mar 19 at 10:57
  • \$\begingroup\$ Ok I added a picture. A vertical line dividing the circle, left being blue for eg and right being green for eg \$\endgroup\$ – Joe Robert Mar 19 at 11:06
  • \$\begingroup\$ Can you come up with a picture of the end result you're looking for, and what are the input images that you'll need? This question is very unclear. And please, put the details in the question, as comments are transient and users don't look for clues in them. \$\endgroup\$ – Vaillancourt Mar 19 at 15:31
0
\$\begingroup\$

If each circle is a separate GameObject and SpriteRenderer then the solution is to use a sprite mask. If you only need to work when they are exactly overlapped, then just check if their positions are sufficiently close. If so, clip them together, and enable a sprite mask on each. The sprite mask should take a white square as it's mask sprite. Position the white square so it IS covering the half you want to HIDE, and NOT covering the half you want to SHOW. I would recommend putting these objects on their own layer, or moving them to a layer that the sprite mask affects, to avoid affecting other objects. You can always move them back to default when done.

If you're looking to blend smoothly in any positions that overlap, you probably need to write a shader, that has a custom blend function. However that's a bit involved for me to get into on this answer, so I would recommend learning some shading skills in unity, which is a process in it's own right.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.