How to select and move units rts style?
Hey all. I've been working on a little rts project and I'm wondering how would I go about setting up a way for me to be able to select unit/s and move them to where I want.
Most of the tuts I find are either extremely outdated, make a point of not using behavior trees or use C++. Since I'm still a huge noob when it comes to ue4 I'd prefer to stick with bps since that's how the rest of my project is.
Ideally I'd left click and drag which draws a box and then any unit in the box would get selected and then I could right click to move them to a location.
Any help appreciated.
asked Feb 26 '19 at 04:56 PM in Blueprint Scripting
below is a simple example of how this could be done. i got the basics for this from Mathew Wadstein who's youtube channel ive linked below. this is also assuming that you want the box select to be in screen space not world.
(First Picture) the important bit here is the get actors in selection rectangle which returns every actor of the filter type under a rectangle drawn on the hud. so each frame we are getting the actors under the rectangle and adding them to an array of selected actors. i added the draw rect at the end to visualize the selection box. also note the use of the gate which serves to enable and disable the selection process and serves to lock in the selected actors.
(Second Picture) to enable the selection i used a simple toggling of the gate in the hud by calling the event on left mouse click and release, dead simple. as for the movement of the characters selected thats really going to depend on your implementation so i just used a simple on right click get teh selected actors, then for each cast to character and ai move. im sure some of the casting here could be avoided and simplified but for proof of concept it works.
answered Feb 27 '19 at 01:49 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here