- Home /
Check if line renderer is completely within a mesh collider,Check if line renderer is within a collider
Hey,
I'm currently facing a problem on my current prototype. The player can drag and drop a line from a start to an end point. I'm using a line renderer component for this which really works fine. Now I have to add a functionality which shows the player if he/she is allowed to drag a line. The player is allowed if the line is completely within a mesh collider. Then the line color should change to green. If the line is outside the mesh collider at any point it should set the line color to red. To clarify my problem I've prepared two screenshots:
In this image the line renderer is completely within the collider (in this case two box colliders which should represent a mesh collider with a non-rectangular shape). The line color should be green.
In this picture the line is slightly outside the colliders. This line should change its color to red.
Do you have any ideas how I can realize that programmatically?
Thanks in advance!