How to offset starting point of a line trace?

Hello. This has been bugging me. I have an AI that performs a line trace in front of it to detect what’s in front of it. However it keeps tracing itself. I made sure to leave the ‘ignore self’ box of the box trace node checked, but that doesn’t work. How can I offset the starting point of the line trace so it starts tracing further out in front of the AI? I tried offsetting by adding float values to just the front axis but that only makes the trace go to the side, not further up front. It’s bonkers because I have another AI with the exact same trace logic and it works without a hitch. Both AI have same collision settings too.

Forward vector * offset amount + world location. Same as how you would get the end of the trace.

1 Like

This is what I did. Do you mean like this? I’m still having the same issue. It’s making the trace parallel to my AI’s body. Maybe I wasn’t clear. I want to offset the starting point of the trace so that instead of starting right at my AI’s chest, it starts to trace further out in front of it.


You are starting from the front and shooting it to the right to a vector with an offset.

Should be:
Forward vector * 50 + world location → Start
Forward Vector * 150 + world location → End

Also suggest you set duration to once per frame so you can see better.

First, you can pass in an array of “Actors to ignore” and there you can pass in your pawn.
My guess is that your AI controller is “self” and “ignore self” doesn’t ignore the actual actor/pawn.
Also, the “end” position needs to be in world space, too.

Also, figure out what direction the vector is going to, and plug in “whatever my start position was” plus “the direction * 40” (or however far you want to offset the start) as the start location. Currently, you’re pushing the vector forward, but you’re tracing to the right – shouldn’t you offset it to the right, as well, then? Also, depending on how big your actor capsule/collision is, you may need to offset it more.


I did like what you told me but I’m getting undesired result. Slightly different though…

I’m not too strong in vector math. I do know I want the trace to be ahead of the lizard. I just don’t want it to start so close in front of it. When I think of an offset, I’m thinking of something as simple as adding 5 units to X, 2 units to Y, and 10 units to Z…

That is not how you offset a trace to always be ahead of the character. You have to multiply the forward vector.

Highly recommend you study this video:
Vectors & Dot Product • Math for Game Devs [Part 1] - YouTube

AI Controller calls this, use Get Controlled Pawn to keep it generic, don’t need to get mesh.

Oh! seems to be a better way to do it. Don’t need to know the AI Controller’s location since it’s not physical and would be potentially buggy to have it use this functionality.

Still have yet to offset the trace further in front of the character. Per @pezzott1 recommendation, it would be good in the future to get acquainted with vector math. In the meantime @jwatte I figured using the “Actors to Ignore” input pin works just fine by not allowing any trace be done on the desired objects in the array.