Line tracing in screen space

Hi! I’m trying to implement an aiming system similar to the one in Weird West (link to provide a more visual example: The Aiming System That Broke Weird West - YouTube, 5:59)

The problem I’m having is that I can’t figure out a way to aim in 2D, like they explain in the video:


For instance in this example, the result should be a hit but it’s not. My idea so far is to get the player’s position in screen space, get the mouse position (same but is in screen space already) and the do a cast from there, but it doesn’t work properly.

Does anyone have a better idea on how this is done? :smiling_face_with_tear:

Isn’t this 3D?

The game is in 3D, yes, but the line trace I want to make I imagine should be in screen space

Ok, me being thick, but I don’t get why. Because it’s actually in game space.

UE does not really have good tools for doing something like that, afaik. I mean, the venerable HUD class can put up world deprojected UI hit boxes up. You’d then need to write a line intersection code.


Instead, would something like this work for you:

:green_circle: stuff we detected
:purple_circle: stuff we can actually see and hit from the character’s viewpoint

The height and distance to targets does not matter, neither does geometry for aiming. Do tell if you think it could work so I’ll clean it up and post it.

1 Like

Hmm this looks very interesting! How is it made? :scream: I would love to try it out and see it if fits

  • long screenshot is long:

yeah, no. Forums do not like high res pics:

  • script:
  • project
1 Like

It’s very very useful, thank you! The only thing that I think will probably be ideal and I’ll experiment with it, is to rotate the plane so that it’s side is always facing the camera, basically being like a big plane-knife cutting the world and testing for traces.
So it looks like a 2D line from the pov of the player, but it’s actually a rectangle.

If you mean the Line Plane Intersection, then yeah - it’s a super versatile approach:

If you feed it camera forward as normal, it’d be a bit like tracing against the inside of a sphere. But I’m not sure I’m fully grasping what you’re after.

Do tell how it goes.

Good luck!