How to check if sphere trace hit is within radius?

Below is the solution I came up with. Seams to work well. Reviewed the BehaviorTree ConeCheck source code and remade the check in BP.

Trace

IsHintInCone

ConeTraceDebug

Basically just do a normal trace. Pass its hit along (IsValid check before passing if you want) and it’ll report true/false if is within your cone radius. It’ll use the trace start/end points to determine the cone size along with your radius. The cone is infinite so you need to be sure your actual trace is as large as you need it to be. I recommend using a Sphere or Box trace for this.

I also added a debug mode to help visualize the hit check and show the cone as well, but you can skip adding that if you don’t want it. I made it a separate function so it’s easy enough to just exclude all that.