Issues with reflecting line trace.

Hey there! I’ve joined a small game jam to try and scratch the rust off of my game dev skills.

So my game idea is somewhat simple, 3D puzzle game focused around redirecting spells shot from a wizard to hit a switch on the other side of the room. I’ve got the reflection of a ray trace working, and I suspect it would work perfectly for fireballs and the like, but I will need ray tracing for a lightning spell, and I’m running into an issue with reflecting mirrors back on themselves. I probably wont design any puzzles to require reflecting mirrors at each other, but it causes issues that the final user of the game may run into (such as rotating mirrors to a new position and crossing paths with the mirror reflecting the current ray to it… it’s kind of hard to explain. I’ll get a video of it happening.

Here’s a video of the reflections working.

And here’s what happens if you reflect a mirror back on the mirror that’s firing at it.

As you can see it sort of loses all the tracing going towards it, and only can regain it if I wiggle the other mirrors around a bit and fire the ray trace at it again.

Here’s the initial code I use to get the wizard to fire the trace. (I set the firing boolean to true in the character controller when the space bar is pressed.)

**Here’s the code I use to get the mirrors to reflect. **

I’d sincerely appreciate anyone’s help. I have a feeling that the raytrace hit event on the mirrors is only able to handle one trace at a time, but all edits I’ve made to it to try and incorporate an array of hits has failed. I really want to be able to stop bumping my head against the wall on this and move on to something else.

You can condense the two separate events that you have by using a recursive function call and passing the reflected normal into the new function.

I would make a new surface type called “Mirror” and allow reflection based on that. The mirror surface would have a material applied that uses a physical material, which uses the Mirror surface type.

EDIT: I goofed on the above Blueprint. Should be a line trace instead of a capsule trace.

This looks really promising! I’ll give it a proper test when I get home from work. Thank you so much for the suggestion! :slight_smile:

It works like a charm! Thanks again!