# What is the most efficient way to trigger an action based on proximity?

I am developing a 3rd person platformer that entails a grapple hook system.

This grapple hook system relies on a series of 'grapple-able' points.

I would like these points to shine every so often.

These points will shine when:

• Within the player's view cone AND
• Within a certain distance of the player.

This Grapple object class will contain the method Shine() to trigger the effect.

Initial research

My initial research was based upon using a cone trace from the player for these Grapple objects, then in each one found, calling the Shine method.

I could then tweak the cone's angle and height to better represent the view cone.

Problems

Unreal by default does not have a cone trace, and I'm not sure if using a multibox trace followed by an angle check is the most efficient solution.

• It sounds like what you really want is a frustum check, not a proximity check or cone check. – DMGregory Sep 5 at 11:33
• @DMGregory that's exactly what I want. Those are more mathematical to do as well. Please excuse my lack of expertise, I haven't programmed in 3 months. Are there preferred ways to do this in Unreal? – Natalo77 Sep 5 at 11:49
• Have you observed any measurable performance impact from the way you're doing it now? Maybe it's fine as-is, and your time is better spent on other parts of your game. – DMGregory Sep 5 at 11:51
• @DMGregory Well, I haven't developed a way to do it yet, and I'd rather go about it the best way. Am i ivory towering too soon? – Natalo77 Sep 5 at 11:57
• Ah, it sounded like you'd tried a box first, then narrowing it with an angle. The thing is that game developers don't necessarily know or care what the "best" way is — we don't typically do proofs of optimality as part of our process. All we know is "solution X was good enough for our needs on game Y". When something isn't"good enough", we profile to identify where the problem is and try to fix that problem. I'd say these checks are unlikely to be what determines your game's performance, so I'd lean toward the simplest way you can try first, then measure to see if there's a problem to solve. – DMGregory Sep 5 at 12:00