Sorry if this should be under UI or something since it involves a drag selection box.
Basic RTS drag selection box that checks a list of selectable units to see if any of them are within the selection bounds. If one is, then it’s ‘selected’. Pretty simple.
It works just fine but I’m just wondering if anyone knows of a better way of checking to see if the bounds contains any gameObjects without having to run through the list essentially every frame of a drag select? I guess I’m just looking to optimize this whole process a little.
Thanks in advance for any advice anyone can offer.
Easiest thing I can think of is to reduce the rate of checking, if it does not make your setup too unresponsive/sluggish. If you do that bounds check every 10th frame for example?
Unless you are running into performance issues I wouldn’t worry too much about it unless you are already in the phase where you are just optimizing your game.
Nah, performance is fine. I’m just going through some stuff and seeing if there’s room for improvement. It only happens when the user is click dragging the mouse so it’s not happening literally every frame of game play.
Seems as though there should be a simpler way to check in any objects exist between a set of (perhaps) viewport coordinates.