Why is my Single Line Trace Not Staying Within Radius

Hello,

I was trying to make a Blueprint Service to detect an enemy once it gets within a certain radius and then set its enum mode to attack. I do have it noticing the player and begin attacking, the only problem is that the radius does not seem to be working for some reason. At some points, the line trace will go far out of the radius and at another point the player is not noticed at all. Any help would be appreciated.

I am unable to post the 5 pictures I took, so here is my Imgur album. Detect Enemy

Line Trace.PNG - This shows where all the enemy detected me and would begin following me.

detect 1-4.PNG - The blueprints.

This doesn’t directly answer the question you asked, but does give you a way to do this that should perform a bit better with lots of objects that can detect enemy units. The I did this for a fun project is to:

  • have an item check the distance between itself and the candidate Pawn
  • if the Pawn is within the radius, then use the Controller of that Pawn for the Line Of Sight To Blueprint node

Because you are doing the less expensive radius check first, with lots of characters/units it will perform better, since the more expensive trace happens only if they are within range.