Download

Line Trace from Actor Location that is always in the same relative direction

Hey All,

I’ve tried looking around for a solution to this and have spent quite some time tinkering with different options but can’t seem to get what I need.

Essentially I want to do a line trace from “Actor Location” to “50 units to the Right”

My idea here is to “get actor location” as the start of the line trace and go 50 units in the x direction. Here is my blueprint:

65150e3ad139f743d74ad99e3a1db20ccaaa8568.png

Why wouldn’t this always go 50 units to the right of my actors location? Do I need to factor in the rotation of the character? I tried to get actor rotation but can’t figure out how I am supposed to combine that with the actor location and then add 50 units of space to the right for the end of my line trace.

Right now with this setup the line trace will always go in the same direction from my actor location regardless of the way i am turning. like below:

1trace.PNG

2trace.PNG

Any help anyone can give me would be greatly appreciated.

Because (50,0,0) is a world-space direction vector.

Try this: instead, use Get Actor Right Vector. This will return a unit vector (length of 1) that always points to the right of the actor’s local rotation. Then, scale this vector by a float value of 50 (using a vector*float node)

This will give you a 50-unit vector in the direction of the actor’s Right. Add this to the actor’s position for the end trace location.

EDIT: note, there are functions to Get an actor’s Forward, Right, and Up vectors. To get more complex, Get an Actor’s Rotation, combine it with a second rotation (e.g. combine with a rotator with a yaw of 25 to get 25° left of where the actor is facing), and use a “Get Rotation XVector” node to get a unit vector which is forward for that rotation.

Thanks Rythm. This helped me get quite a ways last night.

Here is what the working line trace looks like.

00e8cf6b7ec819dfbba848bfa903cbc1c20f793e.png

trace4.PNG

I want to also point out that if you are doing them “forward” and “backward” you need to do something like this:

trace5.PNG

If you don’t add the rotation like this then line trace will be in in angle forward relative to the camera. Causing it to “lean” forward and back depending on the angle you are viewing the character. I didn’t want this but if you fiddle around with these combinations you can do some rather nuanced things.

I know this is super old, I don’t even know if this user is still around but now it seems like this doesn’t work. The line trace is still dependent on the camera. It only changes direction when when the camera moves

@vycanis1801
Where do you put this Graph into?
The Actor itself or a third Actor?

If last, you need to get the playercontroller actor and put its Ref into the Target Pins of GetActorRotation/GetActorLocation… instead, it always gets the Rot/Loc of the OWN Actor…

So… if you put this into a Camera Actor… it will get the Rot/Loc of the Camera Actor itself (therefor… the SELF in the Target)…instead of the Player Actor.