Hi,

I would like the player to select objects in 3D space by drawing a selection rectangle (like in every RTS).

Now, since objects are in 3D that UI’s rectangle is a frustum in the game’s world. So I need to find objects which colliders overlap the said frustum. Is there an already present solution in UE for that?

Alternatively if not I can of course present the frustum as 6 (or 4) planes and check if objects are on the correct side of all the planes. Is there a method to find objects on the positive side of a plane?

Thanks!

So it seems there’s no already-written function to that.

I think I’ll go with the following solution:

- Since FPlane holds the plane in form Ax + By + Cx = D then X, Y and Z coordinates of FPlane are the normal vector of the plane (N0)
- There’s a FVector::PointPlaneProject static method. Use this method to project the sphere center (Rs) onto plane, get Rp
- Rs - Rp is the vector from the sphere center’s projection to sphere’s center. Calculate a dot product of this and the plane’s normal vector: N0 * (Rs - Rp)
- Now, if that dot product is larger than -SphereRadius then the sphere is on the positive side of the plane or intersecting with the plane.
- Do that for every plane in the frustum, if the plane check above succeeds for all the frustum planes, then the sphere overlaps the frustum.

Needs consistent orientation of the frustum’s planes of course.

Here I’d also like to express my disappointment with the fact that FPlane inherits from FVector. A plane is not a vector.

1 Like