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?
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:
stuff we detected
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.
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.