Failing Line Traces

Hello,

I’m working on a light beam puzzle (similar to “LIT: Bend the Light”[LIT: Bend the Light - Full Game Playthrough (No Commentary) - YouTube].)

The puzzle as it stands uses line traces to handle beam collision and puzzle logic, but under certain circumstances, a line trace can pass straight through a static mesh, and I’m not sure how or why.

As an example, let’s say I have 3 actors:

The Source - the actor that generates the beam
The Mirror - the actor that will reflect any beam that hits it
The Wheel - An actor that the player can turn clockwise or counterclockwise. The Mirror is attached to it in level, and so the Wheel turns the Mirror.

When the Source first fires, everything works as expected. I do a line trace from the Source to the Mirror, the trace hits the Mirror where I expect it to, and the Mirror shoots out a new reflected beam from the point where the trace hit its surface.

However, when the Mirror is turned, the impact point changes, so I tell the Source actor to do another line trace to get a new, more accurate collision point.

I do this via Blueprint Interfaces. When the Wheel starts turning, it notifies the Mirror. When the Mirror receives this notification, the Mirror, in turn, notifies the Source. When the Source receives this notification, it begins performing traces (as described above) on tick. When the Wheel stops turning, it sends a “stop” notification down the chain, and the Source stops ticking.

However, when the beam is being refired on tick like this, it will pass straight through the Mirror every three ticks or so.

I’m really not sure why this is happening. Here are a few avenues I’ve explored so far:

  1. Collision Profiles - These have all been checked, and seem fine. I’m just tracing against world dynamic, and all the meshes of all the actors that are a part of this puzzle are all set to world dynamic. At a later date I may move them all over to a custom collision channel, since there are many other actors in the level that aren’t involved in this puzzle whatsoever.

  2. Flaws in Mesh Collision - While I do have custom static meshes with custom simple collision meshes, I also tried using the standard Unreal Engine Cube, and it has the same problem, so I don’t think my custom meshes are the issue.

  3. Tick Groups - Initially I suspected that the Mirror being moved and the trace being performed may happen in the wrong order in a given tick. I’ve tried changing up tick groups, both for the whole actors and for the individual static mesh components as well. I’ve had no luck so far.

Any advice would be appreciated.

Do you have the same 2D setup? Is it possible that the trace goes behind or in front of the mesh at some ticks?

Thank you for your reply!

It’s a 2.5D game, so the setup is similar. The Source does not need to move for the issue to occur, and the Mirror stays on the same plane as the Source as it is being rotated (in my case, y = -950.

Also, I’m not sure if I can post a photo for legal reasons, but when I turn on trace visibility, I do see the trace pass straight through the mesh without registering a hit on the frames when it does miss.

This might not solve your issue directly, but you could simplify this a lot by just having one actor do all the tracing. For example:
1.


2.

3. Set defaults:

TraceBounce

All this does is check if an actor has a valid tag to calculate the new direction and trace again within the bounce limit. Should be easier to debug.

Thank you so much for the reply, and for taking the time to time to demo your solution.

My approach to the core functionality of the puzzle is almost identical to yours, it seems it was my optimizations that were causing issues.

I’ve given up on my previous method for optimization, as nobody I’ve asked IRL has been able to figure out why it wasn’t working. I’ve gone with something simpler that does work, although it is more expensive to run than what I had previously would theoretically cost.