Search Unity

Model Highlight Effect (How to?)

Discussion in 'Scripting' started by par-002, Mar 9, 2019.

  1. par-002

    par-002

    Joined:
    Jul 4, 2012
    Posts:
    52
    I have a model on the terrain that I want to target. When its targeted, it highlights it's range of influence (think of just a typical circle centered at the model with the edge of its influence being the outside edge of the circle).

    Now the tricky part, there is an inside edge of influence (meaning anything too close it cannot influence). So the circle needs to be a ring around the model where the inner arc of the ring is M radius away and the outer edge of the ring is N radius away. Everything in between, inside the ring, needs to have a simple shader.

    Now, I have gotten the ring to work using LineRenderer and drawing it in a circle around the model w/ a line width approximately the distance between M and N. But this seems clumsy and in all honesty I cannot seem to get the inner or outer edge of the ring exactly where they need to be due to it being a width of a line instead of a precise radial distance from the model.

    I don't think an image of a ring w/ an alpha will work for this situation due to the variations of the radius between the inner edge and the outer edge at runtime (i.e. just increasing the size of an image to get the outer edge to work moves the inner edge inappropriately).

    I'm not exactly sure what to call what I'm trying to do. I looked at projections, I looked at sprites... I just can't seem to find what I need for this. Any help would be greatly appreciated!
     
  2. brian1gramm1

    brian1gramm1

    Joined:
    Sep 15, 2017
    Posts:
    56
    Are you saying you want other objects that are between your M and N ranges to have the highlight, or that your targeted object has an image that shows these two values via graphics aka your line renderer?
     
  3. par-002

    par-002

    Joined:
    Jul 4, 2012
    Posts:
    52
    Hey thank you for the reply!

    No, I am saying I need a highlight effect around the objects in the scene. Here's a bad picture :)

    Screenshot.gif

    As you can see, I got the LineRenderer working but not only do the "ends" of the line not work (I get an overlap) but the radius on both the inner and outer part of the ring of the bottom image is not correct.

    I'm not exactly sure what to do here. As I mentioned in the original post, I am not married to the LineRenderer method. Its just the only way I know how to have some little control of the inner/outer radius of the ring.

    Thanks!
     
    Last edited: Mar 13, 2019
  4. par-002

    par-002

    Joined:
    Jul 4, 2012
    Posts:
    52
    I'm sorry, I definitely didn't mean to make this so confusing. I am just trying to put a highlight on an object in the world. I got the LineRenderer idea from this thread: https://gamedev.stackexchange.com/questions/126427/draw-circle-around-gameobject-to-indicate-radius

    Here's an updated version of that screen shot.

    Screenshot.jpg

    Basically, consider an object at game start with a minimum radius of 0 and a maximum radius of 10 for its collider logic.
    After 20s, the minimum radius will switch to 10 and the maximum radius will switch to 20 for its collider logic.

    These values are arbitrary and can be anything during runtime.

    Everything in the "shaded" area of the ring will trigger a collision. Outside that shaded area (including the area < M) will not trigger a collision

    All assets I've found that can do this use a sprite (or texture) that is static for the "ring". My problem is that the inner ring will be incorrect if I attempt to arbitrarily resize it to fit the maximum radius N