- Home /
Dynamic spritemask from worldpoints?
My first question ever on any forum, I know it's a bit too dense, but I tried to make it readable.
The questions:
Is there a simple way, to mask a sprite with a mesh (has no depth, just width and height)?
Could i create something else from this data, that can be used as a mask?
Why I ask them:
I wrote a script based on a blogpost (https://ncase.me/sight-and-light/) that creates a mesh, showing what you can see from the player's standpoint, basically it looks like you are a light source.
This is how it looks (apart from the text ofc):
And a picture with gizmos, blue lines are raycast, and the boxes are raycast hits, incresing in size in sorted order (and changing color from magenta to yellow), sorted by the angular distance from the player.
I am mostly happy with the results, but i wanted to use the created mesh as a mask, so you can only see what is inside it, and the rest of the would remain black, hiding the enemies. (something like this, talking about the blue circle: https://youtu.be/nFR23oru3_U?t=17)
Right now am creating the yellow area, so it kind of would be a solution if created the black area instead, but it would be better if I could use the yellow area to mask enemies.
Your answer
Follow this Question
Related Questions
Normal map on 2D sprite screwed it up.,Applying material with normal map on 2D sprite screwed it up. 2 Answers
I'm experiencing a weird effect with my 2D light. Any fix? 1 Answer
Normal map partially visible through another sprite,2D Normal map causing partial transparency 2 Answers
How to only show sprite with 2D light? 0 Answers