- Home /
Question by
kevin_the_lemon · Feb 23, 2020 at 03:33 AM ·
shadermeshspriterendering
Render sprite only behind mesh?
So I'm making a 2D game and I want to render the enemies (sprites) only when they are behind a mesh I created with a script that represents the line of sight of the player which gets updated as the player move. Are there any ways to do this?
(Purple square is enemy, orange outlines the 'sight mesh' which isn't overlapping the enemy in this photo)
capture.png
(33.6 kB)
Comment
Try a raycast both upwards and downwards (3rd dimension) to test if it collides with the mesh. If it does it is within the line of sight.
Interesting idea but I'm trying to get it to display parts of it even if it's mostly under the mesh. Essentially I want the mesh to act like a mask or a 'window' from which the enemy sprites can be seen.