Rts select and move actors with bps

Hey all I’m trying to figure out a good way to select and move units in my rts game, before I had it set up with c++ but I’d like to have it just be all bps to stay consistent with the rest of my code.

Basically I clicked a spot the computer would “save” that spot I clicked and then when i dragged it would draw a rectangle between the two points and constantly update it, when I let go the rectangle would disappear and any actors that happened to be there would be highlighted. Right click would deselect the actors.

I can’t seem to find any good tuts on this but basically I just really have no idea what nodes this would require, I got the theory and some knowledge on it since I’m assuming it would be pretty similar with nodes.

Any help appreciated.

I’m not sure how you might have had it set up with C++ before you began making the switch, but I’ll describe how I’ve done it for my RTS project, which I hope will point you in the right direction. (I’m using C++ for my implementation, but there’s no reason why it wouldn’t work using only Blueprint.)

  • Store the screen-space position of the mouse (using the Get Mouse Position node) when a selection click begins (you’re already doing this part, I think)
  • Store the screen-space location of the mouse when the selection click is released
  • Loop over all units in the world (try using the Get All Actors of Class node), skipping any units that are invalid for selection (e.g. due to being dead, on a different team, etc.)
  • Project each unit’s world-space location onto the screen (the Project World to Screen node is perfect for this)
  • Check if the unit’s screen-space location is contained within the box made by your two (also screen-space) click locations, which you stored earlier (these two points can be thought of as opposite corners of your selection box)
  • If the unit’s location is contained within the selection box, select the unit

I know that’s a fairly high-level description, rather than a specific example of an actual Blueprint implementation, but I hope it’s enough to help move you forward.

Best of luck!

Yeah this is definitely enough for me to go on and start, Thanks!