Hi, I know this question has been asked dozens of times but truth is that for a complete beginner such as myself, there is not really enough conclusive data on how to pull off a simple RTS Style square selection box. I’d like to be assisted with this providing the following scenario:
I already have the mouse’s start position, released position and a list of gameobjects in two vectors (C#):
Vector2 mouseStart; //already assigned in update method onmousedown
Vector2 mouseRelease; //already assigned in update method onmouseup after onmousedown
List<GameObject> selectedUnits = new List<GameObject>();
Now what code would be required during the update function to return each gameobject in that square into the array of gameobjects?
void update(){
//Code to populate SelectedUnits goes here
}
I have done successful raycasts with a single vector3 which is the camera position, and I’ve read about WorldToViewportPoint and ViewportToWorldPoint but that’s where I get stuck. So any code that explains this (if these are the right methods) and successfully populates my arraylist would be much appreciated, thanks.