Don't want game object seen when it goes past a wall

Hi, so I’m making a game with this robot who has this “scanner.” The scanner is just a gameobject which acts as a visible indicator of where the robot can see. However, if the robot gets close to a wall, the scanner will go through that wall and be seen on the other side. I don’t want to robot to stop before the scanner hits the wall, but instead I want to make the part of the scanner on the other side of the wall invisible. I would also be okay with any other way to make the object be seen on one side of the wall, while hiding the part on the wrong side of the wall! Any help is very appreciated!



I am thinking if you added a collider to the wall you could then collect the point of collision and adjust your scanner length.

Hope this helps!!

@djenningsais Thanks so much for the response! I was thinking about that, however I’m quite new to Unity, and C# in general, and sadly don’t know exactly how to do that! You don’t have to write out the code for me, but if you could point me to a video or document that explains the basics of how to do that it would be amazing!