Search Unity

Polygons with variable opacity edges - what is the way to go?

Discussion in '2D' started by piotrzulawski, Oct 13, 2019 at 12:15 AM.

  1. piotrzulawski


    Aug 27, 2019
    Hello all,

    I am fairly new to unity and I am still figuring out the best practices for doing things in 2D, topd own games. I am currently mapping out the functionalities (and the corresponding Unity tools for achieving those funcitons) that I envisage having in my game.

    One of such things is the characters line of sight. For the purpose of demonstaration, consider this simple scene:

    Here, the red blob is the player, the dark tiles are walls and light tiles are the floor. I want to know what the field of vision of the player is, so I draw some polygons to obscure the player's vision. It looks a bit like this:

    But the shadows look a bit too sharp; I'd like them to have softer edges, going gradually from completely solid in the body towards partial transparency at the edges. I am not sure hpow to achieve this.

    At the moment I am drawing some triangles using the MeshRenderer; they get re-calculated and re-rendered each frame and I am happy with the dynamic effect I achieve this way, but it would look much better with slightly softer edges.

    I was thinking about applying a different material or a shader onto my triangles, but the abundance and depth of choice makes the topic rather difficult to penetrate.

    Any advice for the newbie?