how do i create highlighted region?

wondering how can i create highlighted region while on topdown camera ingame…

like when a player clicks and drag… you create a rectangle…
and the thin rectangle is highlighted to a tinted color…
region is also re-nameable…

so, i’m not sure how to do it.

  1. when player clicks… get world location x,y to a variable [startXY]… (not z - because it is topdown)
  2. then when player releases the left click… get world location x,y to a variable - [endXY]

but im not sure how do i do the dragging part… where theres a visible rectangle as the player drags the rectangle…
and the storing of the area inside the rectangle to a variable… so i can use it laterlike, this object is only placeable in this region…
or sending a unit to a random point in that area…

and even changing the highlight of the region…
and even renaming it…

The rectangle is fairly simple, just make 2 variables: a start corner, and an end corner for your rectangle. When the player presses the mouse button, set the 1st variable to be the ‘Project World Location to Widget Position’ (the World Location input should be the location from (Get Player Controller -> Get Hit Result Under Cursor by Channel)) return value, which will be a 2D Vector (x & y), now do the same thing for the 2nd variable when they release the mouse. You now have two variables representing the top left and bottom right corners of your rectangle. As far as the showing it while it is dragging, instead of setting the 2nd variable when they release the mouse, set it every frame until they release it.

I think i explained it wrong…

But, i wanted to have a rectangular region in the game where it stays visible to the player when crated…

since the game is topdown 2d…

  1. rectangle = created a cube with z scale to 0.1… “region”
  2. rectangle highlight = i created a new material and set opacity to 0.25and a color…
  3. set to variable the trace world location of the mouse press location and mouse release location…
  4. ((2nd point - 1st point ) / 2 + 1st point) = middle of the 2 vector…

so, when the player clicks the mouse…
i spawn the “region” to the world location of mouse press location…
then set new location of region to middle…

so there… i’m stuck with, how do i change the “region”'s scale depending on how the player drags the rectangle…

probably get mouse x and y value, and as the player drags the mouse… ??
mouse press x y value - mouse release x y value = amount of x and y ??
then set it to the rectangle’s size?.. but aint the mouse x and y value is pixel unit?
then how can i convert it to scaling unit?..

im not sure if this is correct… :open_mouth: