Download

Trigger dilemma - is inside geo?

I have a problem with triggering an event. I want to turn something on when my pawn is inside a custom trigger geometry, and off when it’s outside. Sounds simple, maybe I’m missing something obvious.
I’m using on end overlap, or begin, it’s the same problem.
It works, except when you change direction while being overlapped.
Here’s a picture:


I thought having a delay before it resets to being active might be a bit unreliable. I thought I could have a point, like and empty actor to trigger with the geo, as opposed to the mesh of the pawn, but I couldn’t figure out how to do this. I tried a very small sphere, but it had to be very small, which made it unreliable. Adding substeps seemed to make it even more unreliable for some reason. Maybe a volume would be the answer, but this is procedural geo created in another program on a large scale.
I found some posts about finding if a point is inside geo with “get closest point on collision” node, but the geo needs to be convex.
I thought getting the dot product of a line trace direction and the hit face normal would work, but the hit face normal was always pointing towards the camera, so I couldn’t tell if it was a back face or a front face.
I could make it trigger onBeginOverlap and make it impossible to change direction until onEndOverlap occurs, but that could also be unreliable - if you hit it at a grazing angle for example. I’m hoping there’s a better solution.

You have to show the actual code.

Generally,
within each actor
on begin overlap store the actor in a variable cast, check its valid, do whatever else.
on end overlap check if the stored value is set and do what you need if valid - clear the value at the end so it won’t trigger again.

Begin overlap starts immediately.

If you have issues with end overlap going g off with a change of direction, the problem is something else… BUT.

You can cheat and add 2 different pieces of geo.
a sphere within a sphere.
the end overlap of the bigger sphere will trigger after that of the smaller one.
Potentially solving the issue anyway - thing is, you should figure out the actual issue…

Oh thanks. Here’s what I ended up doing - just what you said actually!


trigger_dilemma_solution.png