Help makeing an rts

I am trying to work out how I would wright a script to make the controlls for an rts:
Selecting units
Right clicking where I want them to move
ect

Please help me in any way, shape , or form. If thair are any usefull tutorials for anything else that I might need makeing an rts that would be good

Well, I can at least give you a quick technique for selecting the units. You need to put a trigger collider over each unit with this script attached:

var selected : boolean = false;
var master : MovementScript;

function OnMouseDown()
{
   selected = true;
   master.SelectMe(this);
}

Naturally, the larger the trigger collider the easier it will be to click on it. Also, MovementScript is the name of a script that would hold an array and function like this:

var units : UnitScript[];

function SelectMe(var hit : UnitScript)
{
   for (stuff in units) {
      if (stuff == null) {
         stuff = hit;
         break;
      }
   }
}

The script on the unit would be the UnitScript.

Once they’re selected, all you’d need to do is create a function for movement, targeting, and attacking things that the movement script can send the unit script based on inputs.

I’m making a tutorial series about this in half a month or so, too…

thankyou :lol:

If you want to drag-select multiple units as in many RTS games, you could pull that off by using Physics.OverlapSphere.

Of course there doesn’t appear to be a corresponding Physics.OverlapBox, but sure you could fake that in a number of ways. Not sure if you dynamically create a trigger after dragging it’s dimensions out with a rectangular bounds, whether or not Collider.OnTriggerEnter fires or not. Might be something to experiment with.

Shameless plug.

http://forum.unity3d.com/viewtopic.php?t=18802&highlight=generals

Thank you for this but function SelectMe(var hit : UnitScript) does not seem to work - unexpected var
and something else - does it work for anyone - is it me?