Line trace horribly off-centre

So I made a simple line trace but every time I shoot anywhere else except straight forward the line trace is terribly off-set:


Here’s the line trace blueprint:

Thanks in advance.

You need a “Orientation” trace to get center of screen (down range, crosshair) position.

Once you have that you can do the actual “firing” trace using the result impact or trace end vector.

If you’re doing multiplayer you cannot use the characters camera as a reference for Location or forward vector.

Using the linked code, sequence 3 would do the shooting line trace.
World Location = Start
Select Vector = End

Yeah, I’ll be completely honest I’ve staring at this for 15 minutes and I still have no idea what I’m doing wrong. I tried an alternative where I got the viewport size, divided both X and Y by 2 so I get the center then deproject screen to the world and the other stuff:


But I got the same results as before. Funny enough I’ve always done either this (in rare cases) or the first one and I’ve never had any problems. Is that something from UE 5.3?

I’d start by debugging the values one by one. Is the viewport size correct? Does the DeprojectScreenToWorld bool return true? Can you confirm through your CameraManager (get it through your pawn’s controller) is returning the correct active camera? It’s quite common basic things in UE just break in updates too.

What you were doing on both pictures has a bug though, you are multiplying the end vector with the start vector while you should be adding the end vector to the start position. “Starting from position A go X units into Y direction” is an addition of a vector to the start position, not multiplication.

I guess it was just as easy as that. It’s really not easy when you’re not competent enough to follow a tutorial. Thank you for pointing out the obvious because apparently I can’t do that myself.

Happens to me all the time, take regular breaks it will save time in the end when the mind is not under stress all the time.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.