I’m trying to implement a cone trace by using a sphere trace and checking if the hit was within a certain radius, but am struggling to get the math right (I should’ve paid attention in class!). Below is what I currently have.
I don’t know if GetDistanceWithinConeSegment is the solution or not. Would need someone that’s familiar with it to chime in. Seams to give distance from center line and may not work for an in radius check. Your package is also for a different version of UE than I’m using (5.0) as am waiting for other marketplace plugins to update.
I just can’t understand why there isn’t some form of cone tracing built in. My math solution is the right direction, but my math is off somewhere.
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.