"Opening" 2D circle at random positions

I have a simple circle in my scene imported as Sprite that was made in Photoshop. What I’m trying to do is to make the circle open at certain positions on the circumference which are randomly calculated(second Picture).

My initial idea was to take another sprite, make its color same as the background and place it over the circle. However, I cannot use this approach when I’m working with gradient and more complex backgrounds. Is there a way I could use a transparent object to cover part of an opaque object or any other approach so I would get the intended result?

Brainstorming…

  • You could draw your circle in a PixelSurface, and then easily erase bits of it as needed.
  • If you can make your circle a UI element, you can easily use a Mask with it.
  • You can maybe use the stencil buffer.
  • …Or you can try this sprite mask asset which manages the stencil buffer for you.
  • Maybe you could use Vectrosity to draw just the arcs where you want them.

Hopefully there’s something in all that you can use!

Good luck,

  • Joe
1 Like

Thanks! I’ve looked up different methods and creating shader that only writes to the depth buffer solved my problem. For anyone, this post helped me out: Can I obscure an object using an invisible object? - Questions & Answers - Unity Discussions

1 Like