unity backgrund image

Hi
I am new t unity and now developing a 2D game. The game has a background image and what I want to happen is that when objects move out from over the image area they should automatically disappear partially or fully.

I am a long time programmer I am able to develop the game quite easily but mostly having problem in placing objects and display issues.

So any advice would be appreciated

1 Answer

1

One way would be, if the background image is a square, to get it’s screen rect with Camera.WorldToScreenPoint, then the position of te object and use Contains.

An other way, harder one, is to use shaders and alpha to simulate a stencil buffer. Good luck with that, personnally I wasn’t able to make the stuff in the link work.