October 25, 2023

dealing with overlaps

Now that the modules can be moved around I’ve discovered some unexpected fuckery with the way I’m handling the placement of lights.

In Rack there are only 2 dimensions to deal with, so as long as the lights are drawn on top of everything else, they’ll always be in the right place. In Unreal I have a third dimension to contend with, and when I encounter a light and another object—typically a button or a slider handle—occupying the same space, I need to move the light forward to rest on top of the other object.

I’m handling this by setting the lights to respond to overlap events. The problem is that things are moving now, so overlaps can happen as a result of someone (me) swinging a module around (wildly, for fun). There are a few things I end up doing to mitigate this issue, and some other issues I find along the way:

  1. Only handle the overlap event the first time it’s fired.
  2. Only allow overlaps from other components owned by the same module.
  3. Rewrite the code that moves the light. It’s supposed to move an amount equal to the height of the overlapped object, but sometimes it would move double the distance.
  4. And, because lights would occasionally overlap with things that were nearby but not really touching, I tightened up the collision handling by setting some components’ “collision trace flag” to UseComplexAsSimple. This uses a shape closer to the mesh’s actual shape instead of a simple box.

Somewhere in debugging this I made the lights extra tall and exaggerated the location shift. Can’t figure out why something is doing something? Make it do it more!

All that taken care of, lights now end up where they're supposed to be and then stay there.