Rts people select

Im trying to help a friend create a RTS game and i want to program it so i can create a box by clicking down on my mouse and dragging it and what ever is in the box gets selected this is what is have so far

using UnityEngine;

using System.Collections;

using System.Collections.Generic;

public class RTStargeting : MonoBehaviour {

public Transform selectedTarget;

void Update(){

if (Input.GetMouseButtonUp(0)){ // when button clicked...

  GUI.Box(new Rect());
}

private void SelectTarget(){

selectedTarget.renderer.material.color = Color.red;



}

private void DeselectTarget(){

if (selectedTarget){ // if any guy selected, deselect it

  selectedTarget.renderer.material.color = Color.blue;

  selectedTarget = null;



	}



	}

}
i have no idea what to put in the GUI box can anyone help me alter or complete this script so that when i click down and darg my mouse it creates a box and whatever character that are in it get selected

Well you need to find your two points in the world to draw your box. I would probable setup a plane with a collider that represents your ground and raycast from your mouseposition using the camera to ray function ( on phone so can’t look up docs ). Then store the raycast hit point into a vector3 on mouse down then while the mouse is down update you box to draw in world space from your starting vector3 to your current mouse position hit point. Once you define that area all you have to do is determine which Targets are in that area.

Hope that helps.

http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html

find mouseposition using raycast