Triangle formed is still shown

I have three frame markers and there are three balls being shown above them.I have drawn a line between each two balls using lineRenderer thus forming a triangle.
When I move the marker away from the camera view then the balls disappear(as should be) but the triangle is still displayed.
How do I make the line also disappear when it can’t find the ball or frame marker?
I am coding in c#
Please help guys
Thanks :slight_smile:

You’re thinking about the problem the wrong way. The idea is for the human to think it’s real, and that the lines wink out because it couldn’t draw them. But, it’s really just all faked, by you. There’s no relationship to how easy something is in real life, to how hard it is for the computer to fake it.

You have code drawing three lines, connecting three balls. You want code for one line connecting two balls. Then, there are three possible pairs of two balls (AB, AC and BC,) so figure out how to make each of those lines.

Probably the 2-line code will be similar to the 3-line code, but simpler, or maybe not. Probably each of the connect-2-balls lines will be the same except for the variables. Or maybe not. There might be a nice way to combine all the code into one chunk the skips off-screen ball-lines. Or there might not be.

When you’ve got all three new 2-line codes written and tested, you just have to switch between them. If ball B goes off-screen, stopping running the 3-line code, and run the “make the AC line” code.

As rutter said, you can disable the LineRenderer all together, or use .SetVertexCount(0) on it.