I currently have a trace set up between a guard and the player character which runs through a series of checks
first: does the player character exist
second: is it within range
third: is it within a cone area determined by getting a forward vector from the guard, comparing it to the direction of the component, and if the arccos of the direction of the player and the forward vector are less than an angle I set up as a variable then it counts as true
if all of these are true, then you’re detected and you lose
however the problem comes in check 3, because it uses the location of the component that it hits (aka the middle of the character model) to measure the angle, then you can be half inside the trace zone and not get tagged.
I’ve tried swapping the line trace out for a box trace hoping that maybe it would take the whole box into consideration when determining the angle but this isn’t the case.
What I’d like is one of the following
1: finding a way to make it so if any part of the hit component crosses that threshold then it’s tagged
2: finding a way to make it so if any part of a box trace crosses the threshold then it’s tagged
the first check might not be as meaningful as you think, the engine will try to optimize either through world partition or just distance (depending on the project) what actors are “awake” or set to “sleep” and for most of the systems in the engine “if the player doesn’t exist something is very, very wrong” so that check should always be true… (unless you mean something like “if the player is within a given room” then that might be more meaningful)
it might depend on how much “faking you are OK with” the ‘simple and dirty’ approach would be to add just some SceneComponents TrackingPoints (so that we have the transform exposed, this is very similar to how real world MoCap works) to the playerPawn that are strategically placed around the pawn just outside of the Mesh, you should only need like 8 or 9, and parented to the collider (this way it moves around with the player).
-in the BeginPlay of the ActorComponent have it get the references to these TrackingPoints, then after on success to distance check and grabbing the ActorComponent you do the Line Of Sight checks on these TrackingPoints and if at least 2 or 3 are true then the Player is visible
another more specific approach that is similar would be to give the PlayerSkeletalMesh some sockets at strategic points, then given this ActorComponent a function that like returns the WorldLocation of the given socket (this is because the WorldLocation of Socket requires the “exact” name of the socket, so to minimize the potential of misspelling socket names localize them to the owner of the sockets) then do your Line of Sight checks to the sockets (this way they move with the bones of the SkeletalMesh so for example you put one of these sockets on the knee-cap during the crouch animation the socket will still be on the knee-cap)
I suggest having more then one of these points being a positive Line of Sight before fail-state because I personally dislike games being just slightly lax to the player. Sure, have the agent be more interested in seeing a single point, or even a specific point to investigate, but personally I would say “don’t fail them because the elbow was poking out for a single frame”