Draw Rectangle in World Space? (Box Selection)

How would I go about creating a box selection that goes off of mouse position in world space and not screen space? Both “Draw Rect” and “Get Actors in Selection Rectangle” nodes only work with 2D Vectors created using “Get mouse position”.

“Get mouse position” → “Convert Screen Space to World Space” doesn’t work.

You can get the mouse position in world space at any time, so maybe save it when it’s pressed for corner one and when it’s released for the opposite corner.
From there on you have multiple ways of getting the actors in that box. I’d probably try by spawning a collider box from one corner to the other and getting all colliding actors in it.

For your problem with: “Get mouse position” → “Convert Screen Space to World Space”;
There’s a function called “GetHitResultUnderCursor”, which is basically a line trace onto whatever the mouse is over (FHitResult is used and returns the impact position).

BoxSelection_2d_3d
Red rectangle - 2d selection (HUD).
Blue rectangle - 3d selection area.
Download Example
Left Mouse Button - 2d.
Right Mouse Button - 3d.



For 3d, I prepared only the selection area.
You should think about implementing a selection of actors in 3d mode.

My Products

3 Likes

I still can’t believe that this is not a standard feature in Unreal, drawing selection rectangles has been a standard in the design industry for ages. How then do you select a group of objects that have no common qualities but their presence on screen ?

Spit balling, anything you want to be able to select could all share the same parent actor?

Also, I’m not sure but couldn’t you also use the generic “actor” class, and create a custom trace channel? Not sure if the get actors in rectangle node functions the same as the under cursor node and you can break it up and work with whatever blocks said trace channel.

Tbh, it is a built in feature… You just have to press Ctrl + Alt and draw a rectangle with the mouse in the world editor

1 Like

Is this for developmental/functional purposes while creating the game?

I was meaning a rectangular selection for the actual game play.

Really, that is a bit of a workaround for such a basic functionnality, anyways thanks I’ll give it a try and report