Trace from the camera straight into the screen


I’m trying to do something as simple as line tracing from the camera (well, center of the viewport) straight “forward” into the screen, as in trying to check what the “crosshair” is on as far as the player is concerned.

I tried just grabbing the camera in the 3rd person example and tracing forward but I get weird results. The origin is seemingly offset and shoots in weird angles. The red line is the trace and the sphere is the impact point.



I’m probably having a temporary brain malfunction, but if someone could point me in the right direction, that would be much appreciated.


What are you using to set your Follow Camera variable?

That’s just the camera component already in the 3rd person example that’s part of the Pawn blueprint.

Start = StartLocation
End = StartLocation+Direction

1 Like

Start -> Camera
End -> [amount] units in forward of camera


This is correct. The Start is a point in 3D Space. You have the Camera Location for this.

And the End point is also a point in space.

You have the forward vector (which is normalized) for this and you multiply it by 5000.
If you only take this multiplied vector, you will begin from (0,0,0) with this endpoint and the point will be, for example, at (5000,0,0).
But you want to start at the starting point of your trace. So a small number example:

Starting Point is (200,200,80). You are looking dirctly along the x axis, so the normalized forwardvector is (1,0,0). You now want to scale it by 5000,
so that the point is 5000 unity further away. So the point is (5000,0,0). If you only take these, you will trace from (200,200,80) to (5000,0,0).

But that doesnt seem right, does it? If you look dirctly in x direction, you would have the same y and z coordinates like the starting point. So it is missing!
Add the starting point and you have (5200,200,80) and you will have your correct trace!

Maybe try drawing vectors in 2D space on a paper to get the idea behind it (:

D’oh! Of course! Thanks!

Yeah, as expected - just adding the camera location to the offset did the trick. One node…

Thanks, much appreciated.