I made this project a long time ago so I decided to make some changes to create this effect. I believe that I was using this as a laser pointer for one of my shooter games to stop going forward when it touches the edge or enemy.