Plane Trace between two points on the screen

This is less of a technical problem and more of a math problem. I want to do a trace between two points on the screen, infinitely in distance from the direction from the cameras vector. I’ve been trying to use a box trace that is very thin. But my problem is trying to affect the box rotation that it is aligned to the camera.

Basically I want to shoot out a rectangle from 2 points on my screen and get everything in between them. If there is an actual way to do this other than a box trace I would appreciate that too.

If I’m not explaining this well enough, I can post images when I get home from work.

Use the camera forward vector. Use the LookAt node to look at that forward vector to get a rotation for the cube that always faces the same as the camera.

Here’s a full paste of my solution.

  • [Plane-trace from camera][2]

You can try something like this:

It creates a virtual box between 2 points and gets all overlapping actors with the required collision preset. Is you want this box to be closer to a plane, just don’t use the Box Extent Z, simply give it a value of a few units, and don’t use Box Pos Z, set it to the Camera Z Location.

But this box uses world coordinates, so if those two points are quite far one from another, the box extent will be very large, and its other corners may overlap lots of actors, so keep that in mind.

Hey Thanks Ben,

Since I wanted the ray to cast from a location to location and not from screen to location I had to go through the the up vector instead. The results are perfect. Thanks a ton.