Line traces do not hit center of NPC actor

Hello,

I’ve built a system to generate line traces at a number of different actors in my level, and this is working fine for all but one–an NPC actor that I’ve created using one of the built in Manny skeletal meshes. For some reason the line traces are always off. Here’s the blueprints for the line trace targeting and an example of the results:

Does anyone have any ideas or guidance on how to troubleshoot or fix this?

You’re adding location and bounds together, which is offsetting the end by the direction away from center of capsule to something’s bounds (multiplied by some float).

What is the blue wire headed off screen in the top left connected to? If that’s the target actor, get its location and plug it into end on the trace. Or use find lookat rotation from start loc to the target’s loc, get forward vector from that, multiply forward by the radius float, and add that to start loc to make end value.

Or if you’re just trying to see if an actor is close enough to another actor to use it, you could skip the line trace, and use the Get Distance To node and plug both actors into it. Then check if result <= your Activation Radius float.

The blue wire to the left is a for each node which is pulling a reference to each actor (including this one) in an array of actors at which I want to fire line traces.

I was originally using each actor’s location as the end point for the line trace, but I discovered some actors have their origin point at a position which is not their center. For example, a door may have it’s origin at its bottom left corner. This is why I was using the Get Actor Bounds node and using its origin output, and it’s worked fine for all the other actors I’ve used this blueprint with, except this one.

To add a little more context on what I’m doing with this, the line trace system is meant to approximate the movement of sound in the space and determine whether or not an actor is close enough to ‘hear’ the sound and whether or not there’s an obstruction between the player and the actor that might block the sound. I know there’s an AI sense for this, but not all the actors that respond to sound are AIs. I’m also using this to check if a surface is close enough to reflect the sound.

If you really want to see everything in action and understand it all, I’ve been recording short video demos of my progress as this is my master’s project for school:

Regarding your suggested node sequence, would that look something like this:

Ah, makes sense why you used bounds now. I misread first screenshot and thought you were using bounds extent for the math. So the pawns are basically using echolocation? Clever!

As for updated graph, you don’t need to convert rotation to quat or normalize, forward is already a unit vector. Just plug the Find Look at Rot output into a regular get forward vector node, multiply that by radius, and add to trace start.

Sorta like this:

Junk at the top is just quick filter of a sphere multi-trace so it only line traces once per actor (since multi trace can sometimes doubletap lol)

If the line still wanders, it could be Manny has a wonky physics asset body that’s shifting the actor bounds origin.

Thank you for the suggestion and image.

I have tried the alternate node sequence you’ve suggested and the outcome is the same as the original sequence I had in place–the line cast misses this actor.

You mentioned that there could be an issue with Manny’s physics asset body. I looked through the PA_Mannequin and didn’t see anything that looked amiss, but I also don’t know much about these things. How would I go about confirming there’s nothing amiss with any part of the mesh?

Update:

I did some more research and testing into this problem and I believe I have discovered the source of the issue as well as the solution.

In Unreal Engine 5.6.1 (the version I am using), Character blueprint actors come with an arrow component built in as one of the base components, and you cannot remove this component. In testing with a test Pawn blueprint actor that I created where you are not required to have an arrow component, I found that my line traces were on target. However, the moment I added an arrow component to that pawn blueprint actor, the line traces were off again.

Since you cannot remove this component from the Character actor blueprint, I tested making a small change in my line trace generation system:

By checking this box for Only Colliding Components, I can ignore components of the actor (like our troublesome arrow component) that don’t have collision enabled. Once I turned this on all my line traces started targeting my NPC blueprint actors correctly.

Edit:

Here is a link to a video I made that outlines my solution as well as some helpful context:

Good catch. Yea. this looks like it was the problem. I edited the characters’ interaction interface in my game to draw a debug box at bounds origin, and it was a bit in front of them like your Manny pawn (was even a bit worse for me since my characters are 120-128cm tall goblins and the default arrow is about as long as their height lol). Not sure how I missed that one before. Must’ve missed it since there were so many lines flying around in my array line trace event above. But, yea, ticking Only Colliding snapped the origin back to center of capsule if they were standing up.

If you’re feeling adventurous, another option would be to make a new c++ class for your project’s characters and scale or destroy the native arrow component in constructor. Just be sure to Super call parent constructor so it’s valid before trying to do anything to it.