Need help with Reflecting Light Script

Hi all. I could really use some help with this school project, and hopefully a portfolio piece:
So, the game is a puzzle room inside of a dungeon or cave. There is a piercing light coming from the ceiling, and the purpose is to rotate the mirrors in order to reflect light until it hits a switch in the wall in the upper right (NE) corner of the room. There are falling boxes from a box spawner that explode on a timer. If the player overlaps the box, the player takes damage. When player health is at 0, the player loses. If the player manages to get the light to hit the switch in the corner and exits the room, the player wins.
I have three major problems:

Problem 1 is that I have a spotlight attached to each mirror that is set to invisible unless the it is hit by the piercing light or the reflect function. If hit by a line trace, the spotlight becomes visible and shoots straight out of the front of the mirror. I’m trying to reset the position of the spotlight and the light cone texture so that is spawns at the right rotation angle and transform as where the line trace hit.

Problem 2 – This is actually the biggest problem I feel. Let’s say I have 4 mirrors reflecting off each other properly, but I decide to rotate the first mirror in the chain, it doesn’t break the reflections on all the mirrors. Only the previous mirror that reflects the light is broken. Mirrors 2 and 3 remain shinning a light forward despite not getting the initial light source coming to it.

Problem 3 – The game crashes. I created an exploding box BP and the root component is a destructible mesh. I’m not sure if that’s why the problem is occurring, but I have boxes that randomly spawn from the ceiling and explode on a timer. After about the 7 or 8th box, the game either completely crashes, or hangs for 3 to 5 seconds before resuming. I did notice that this demo uses a ton of memory and CPU power. It barely hiccups on my gtx 970, but when I try to run it on a slower computer it almost always crashes the game.
Here are a list of major BPs that are causing the problems:

Problem 1 -

Problem 2 -

Problem 3 -

Piercing Light BP (initial light from ceiling) -

Reflect Light main recursive function -

Exploding Box BP -

Exploding Box specific function -

Don’t use lights for it. Just use static meshes that fake being like lights.

I appreciate you attempting to answer my concerns. I actually have both. I already use a cone mesh with a translucent material for the light beam affect. The problem isn’t as simple as replacing a light. The reflect light works, but it doesn’t reflect from the proper angle. I need to transform and rotate the light and cone mesh to start firing out from the point where the impact hits from the line trace. The bigger problem is that when a light starts to bounce off multiple mirrors and you change the first or 2nd mirror not to properly bounce the light, the mirrors further down the reflect chain continues to to shoot light despite it not receiving a light source. I could deal with the first problem, but I tried for days to solve the light reflecting off a mirror despite not receiving a light source. It makes the puzzle confusing and almost non-playable. Thanks again. :slight_smile:

You can attach your “light” mesh to a socket on your mirror and it’s angle should match the angle of the mirror exactly. Then to spawn the next light on the next mirror you just do that on overlap from the other mesh. So if there is no light mesh overlapping the mirror then it removes the light mesh it’s spawning.