Okay, I see where I went wrong with the first option. Since it’s only getting the distance from the character to the camera, all of the line trace end points are basically on a giant sphere with the camera as it’s origin, which is why they’re skewing away from the character. To fix this, we’re going to change some things.
First, so that we know the line trace will be on the same plane as the character, we’re going to make a new vector that uses the character’s X location as it’s own X. Next, break apart the vector we were using as an endpoint, and plug the Y and Z values into our new vector. If we were to plug this new vector into the end point of our line trace, we’d see that the trace wouldn’t make it to the mouse cursor, but it would still always point at the mouse and always be on the same plane as the character, which is a good start for the second part of the fix: extending the line beyond the cursor.
Now that we know we just need to extend the line trace into the distance, here’s what we’re going to do. We take our new vector, and subtract the player’s location from it. This gives us a directional vector from the player to the cursor. If we normalize this vector so that it only has a length of 1, we can then multiply it by any float to make it whatever length you need. Now we just add the player location to it and plug it in as the end point to our line trace.
And if you need help following all of that, here’s the new blueprint structure: Answerhub Linetrace Revised A posted by Cage518 | blueprintUE | PasteBin For Unreal Engine 4
And there we go, a trace from the character to the mouse that extends into the distance.