I'm working on a game that's quite similar to probably what a lot of people are doing, but as this is my first attempt to make a game in Unity that wasn't just a textbased adventure, I thought I'd just go for it. The game will involve bouncing a mounted laser off of mirrors to hit a target at the end of a first person maze.
For the last few days, I've been struggling with a problem with my laser. Until this morning, I thought the problem had to do with getting it to stop when it hit a target that wasn't a mirror. It would, seemingly, veer off randomly when I added the if statement to check for collision. However, in setting up to make the video below, I discovered the problem goes deeper. It's happening whenever I increase the number of reflections past two. The script I use, which I based off a somewhat outdated tutorial, seems to be seriously flawed. However, with my admittedly limited understanding of LineRenderers, I'm not sure where the problem lies. I'm fully willing to start from scratch on this, but if this tutorial isn't working I really don't know where to start.
Since I know I'm not the only one working with reflecting lasers in this game jam, can anybody possibly point me to either where I went wrong, or point me towards a line reflection tutorial that will give me a better place to start?
The script in question: Github Link
Video demonstration: